How can I get a similar function with pack/unpack (or other short function)?
function getHEX($number) {
    switch($number) {
        case 0: $ret = "\x00\x00\x00\x00"; break;
        case 1: $ret = "\x00\x00\x00\x01"; break;
        case 2: $ret = "\x00\x00\x00\x02"; break;
        case 3: $ret = "\x00\x00\x00\x03"; break;
        // (...)
        default: $ret = "\x00\x00\x00\x00";
    }
    return $ret;
}
                You could do it with dechex in PHP:
<?php
echo dechex(10) . "\n";
echo dechex(47);
?>
                        Here is a hint:
str_pad(dechex($number), 4, "0", STR_PAD_LEFT)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With