Can someone suggest a (preferably) graceful way to convert an ASCII character to its decimal equivalent using PHP?
+1
A:
function ascii_to_dec($str)
{
for ($i = 0, $j = strlen($str); $i < $j; $i++) {
$dec_array[] = ord($str{$i});
}
return $dec_array;
}
example usage :
$ascii ="\t";
print_r( ascii_to_dec($ascii));
returns an array
Array
(
[0] => 9
)
streetparade
2009-12-02 22:11:35
Thanks for the help!
Jim Fell
2009-12-02 22:25:09
you are welcome
streetparade
2009-12-02 22:32:46