I'm investigating encodings in PHP5. Is there some way to get a raw hex dump of a string? i.e. a hex representation of each of the bytes (not characters) in a string?
+3
A:
for ($i = 0; $i < strlen($string); $i++) {
echo dechex(ord($string[$i]));
}
or easier
echo bin2hex($string);
Stefan Gehrig
2009-06-29 10:17:01
Or a more functional approach:print_r(array_map('dechex', array_map('ord', str_split($string))));
Ionuț G. Stan
2009-06-29 10:29:50