<?php
$str = 'nilpointer.net';
$hex = array();
foreach (str_split($str) as $chr) {
$hex[] = sprintf("%02X", ord($chr));
}
echo implode(' ', $hex);
?>
Output
6E 69 6C 70 6F 69 6E 74 65 72 2E 6E 65 74
<?php
$str = 'nilpointer.net';
$hex = array();
foreach (str_split($str) as $chr) {
$hex[] = sprintf("%02X", ord($chr));
}
echo implode(' ', $hex);
?>
6E 69 6C 70 6F 69 6E 74 65 72 2E 6E 65 74