Jump to content


This topic is now archived and is closed to further replies.


getting an ascii value of a letter

Recommended Posts

hi i wrote a small encryption routine in visual basic and ported it to a few other programming languages but i really want to use it in php. However is there a function so i can get the ascii code for an individual letter and is there a way that i can pick each letter of a string individually for example


will loop and get T

then will get ther ascii of t 45(this may not be the actually number just showing as example)

then after it does that it moves to the next letter which is r

then to e then to e after that
and so on and so on

any help would be great thanks

Share this post

Link to post
Share on other sites
Use the [a href=\"http://www.php.net/ord\" target=\"_blank\"]ord()[/a] function and a for loop:
$str = 'This is a test string';
    echo $str{$i} . ' = ' . ord($str{$i}) . '<br>';


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.