Convert Character To Integer (ASCII)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
niaher
Forum Newbie
Posts: 3
Joined: Thu Apr 17, 2008 12:51 am

Convert Character To Integer (ASCII)

Post by niaher »

Hello PHP people. Can anyone please tell me how to convert character to integer (ascii code that is)?
I know in C++ you can do it simply:
char c = 'a';
int ascii = c;

Thank you in advance :D
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Convert Character To Integer (ASCII)

Post by Christopher »

(#10850)
niaher
Forum Newbie
Posts: 3
Joined: Thu Apr 17, 2008 12:51 am

Re: Convert Character To Integer (ASCII)

Post by niaher »

Just found the solution. Use ord(string character) function.
If anybody knows a different way, please post it :wink:
niaher
Forum Newbie
Posts: 3
Joined: Thu Apr 17, 2008 12:51 am

Re: Convert Character To Integer (ASCII)

Post by niaher »

Wow that's a fast reply, not even 10 minutes I think. Thank you arborint.
Post Reply