note
ikegami
<p>That's a totally pointless requirement, but the following does achieve it:
<c>
$hex = sprintf('%X', oct("0b$bin"));
</c>
<p><c>oct</c> converts the binary representation of the number to a number, then <c>sprintf '%X'</c> converts it to its hex representation. It's never represented in decimal.
<p><b>Update</b>: Or maybe you're actually interested in converting bytes to their hex representation:
<c>
$hex = sprintf('%02X', ord($byte));
</c>
644225
644225