In Perl I have code that is working correctly:
print unpack('B*','10071C2');
returns 00110001001100000011000000110111001100010100001100110010
The code ported to PHP using GMP:
function gmp_convert($num, $base_a, $base_b)
{
return gmp_strval ( gmp_init($num, $base_a), $base_b );
}
$test = "10071C2";
$testb=gmp_convert($test, 16, 2);
produces 10000000110110001110000101001101111110110001101110000111
I thought it might be byte order, however if I use b*
instead in Perl it still produces something else:
PHP---10000000110110001110000101001101111110110001101110000111
PERL--10001100000011000000110011101100100011001100001001001100
I simply do not understand this, can anyone help?