[PHP-TEST] HEX2BIN

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function convertHexToSym($str) // Converter from HEX to Symbols
// Ex.: 48656C6C6F2C20776F726C6421 -> Hello, world!
{
$len_str = strlen($str);
$array = array();
$edit = substr($str, 0);
for ($i = 2; $i <= $len_str ; $i += 2) {
$n = sscanf($edit, "%02X", $val);
if ($n > 0) {
$buf = sprintf("%c", $val);
$array[$i] = $buf;
$edit = substr($str, $i);
}
}
$out = implode("", $array);
return $out;
}