Since I am never able to remember this, I decided to write it down here.
The code is the following :
function showByteSequence( $string )
{
for ( $i = 0; $i < strlen( $string ); $i++ )
{
echo '0x', dechex( ord( $string[ $i ] ) ), ' ';
}
echo "\n";
}
For example writing
showByteSequence( 'foo-bar' );
should display
0x66 0x6f 0x6f 0x2d 0x62 0x61 0x72













Kore has his own function as well :
http://kore-nordmann.de/blog/php_charset_encoding_FAQ.html#how-do-i-iterate-bytewise-over-a-string