How do you convert a hexadecimal representation of data to binary data in PHP?
- by Marcus Adams
I'm familiar with php's function bin2hex() for converting binary data to its hexadecimal representation.
However, what is the complement function to convert the hexadecimal representation of the data back to binary data?
For example:
$foo = "hello";
$foo = bin2hex($foo);
echo $foo; // Displays 68656c6c6f
How do I turn it back to hello?
$foo = "68656c6c6f";
// Now what?
There is no hex2bin() function.