Page 1 of 1

Convert Character To Integer (ASCII)

Posted: Thu Apr 17, 2008 12:59 am
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

Re: Convert Character To Integer (ASCII)

Posted: Thu Apr 17, 2008 1:08 am
by Christopher

Re: Convert Character To Integer (ASCII)

Posted: Thu Apr 17, 2008 1:09 am
by niaher
Just found the solution. Use ord(string character) function.
If anybody knows a different way, please post it :wink:

Re: Convert Character To Integer (ASCII)

Posted: Thu Apr 17, 2008 1:11 am
by niaher
Wow that's a fast reply, not even 10 minutes I think. Thank you arborint.