Connecting Tech Pros Worldwide Help | Site Map

Getting ascii value of a char

Aaron Gray
Guest
 
Posts: n/a
#1: Mar 24 '08
Given :-

$text="abc";

$ch = $text{0}; // index character 0 in $text

how do I get the value 65 from $ch as an integer ?

Many thanks in advance,

Aaron


=?iso-8859-1?Q?=C1lvaro?= G. Vicario
Guest
 
Posts: n/a
#2: Mar 24 '08

re: Getting ascii value of a char


*** Aaron Gray escribió/wrote (Mon, 24 Mar 2008 20:50:18 -0000):
Quote:
$text="abc";
>
$ch = $text{0}; // index character 0 in $text
You'd better get used to $text[0]. Apparently, the PHP guys will deprecate
the first syntax in PHP 6.

Quote:
how do I get the value 65 from $ch as an integer ?
ord()


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aaron Gray
Guest
 
Posts: n/a
#3: Mar 24 '08

re: Getting ascii value of a char


"Álvaro G. Vicario" <webmasterNOSPAMTHANKS@demogracia.comwrote in message
news:16xr3ovmn0j4k$.1ik3o5ph82kjb.dlg@40tude.net.. .
Quote:
*** Aaron Gray escribió/wrote (Mon, 24 Mar 2008 20:50:18 -0000):
Quote:
>$text="abc";
>>
>$ch = $text{0}; // index character 0 in $text
>
You'd better get used to $text[0]. Apparently, the PHP guys will deprecate
the first syntax in PHP 6.
Okay, thanks.
Quote:
Quote:
>how do I get the value 65 from $ch as an integer ?
>
ord()
Great, thanks alot,

Aaron


Closed Thread