Can someone suggest a (preferably) graceful way to convert an ASCII character to its decimal equivalent using PHP?
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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With