hex value to string of characters

442 Views Asked by At

I have a hex number that I get from a bin2hex() call. I need a string representing this number in the format outlined below:

$tmp = bin2hex($foo)
// $tmp is 0x123efd

I need some code that will give me the string "123efd".

1

There are 1 best solutions below

0
On BEST ANSWER

It is a prefix of hexadecimal (0x). You need to remove the prefix with

$tmp = substr(bin2hex($foo), 2); // $tmp is 123efd
//assume that prefix is only 2 digits and you always remove the 2 digits