I need to convert a binary string into a hex string. This code works fine:
<?
$binary = "1111111111111111111111101000011111111111111111110000001000100100";
$hex = dechex(bindec($binary));
echo $hex;
?>
However, if I add one extra bit (or more) to the binary string, the result just comes back at 0.
<?
$binary = "11111111111111111111111101000011111111111111111110000001000100100";
$hex = dechex(bindec($binary));
echo $hex;
?>
I guess I can break up the binary string into chunks and then combine the hex value at the end, but is there any easier way?