Connecting Tech Pros Worldwide Help | Site Map

Getting ascii value of a char

  #1  
Old March 24th, 2008, 09:55 PM
Aaron Gray
Guest
 
Posts: n/a
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


  #2  
Old March 24th, 2008, 10:25 PM
=?iso-8859-1?Q?=C1lvaro?= G. Vicario
Guest
 
Posts: n/a

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
--
  #3  
Old March 24th, 2008, 10:55 PM
Aaron Gray
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASCII Character Codes Chart 2 Marcel Saucier answers 18 February 20th, 2006 09:45 AM
Getting Error in Login() method in FtpConnection Class ruju00@gmail.com answers 0 February 1st, 2006 10:15 AM
Getting an ascii value from a byte James Dean answers 1 November 16th, 2005 09:09 AM
[c++] getting the ASCII value of a char Haas answers 6 July 23rd, 2005 04:12 AM