- strtoupper: documentation ( source)
- dechex: documentation ( source)
- strtolower: documentation ( source)
- str_pad: documentation ( source)
<?php
for ($i = 0; $i < 256; $i++) {
$str = str_pad(strtoupper(dechex($i)), 2, '0', STR_PAD_LEFT);
$p1 = [$str[0]];
if ($str[0] >= 'A' && $str[0] <= 'F') {
$p1[] = strtolower($str[0]);
}
$p2 = [$str[1]];
if ($str[1] >= 'A' && $str[1] <= 'F') {
$p2[] = strtolower($str[1]);
}
foreach ($p1 as $c1) foreach ($p2 as $c2) echo "const \\x{$c1}{$c2} = \"\\x{$str}\";\n";
}