How to convert hexadecimal representation of data to binary data in PHP?
        Posted  
        
            by Marcus Adams
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Marcus Adams
        
        
        
        Published on 2010-04-08T19:29:18Z
        Indexed on 
            2010/04/08
            19:53 UTC
        
        
        Read the original article
        Hit count: 486
        
php
|string-manipulation
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.
© Stack Overflow or respective owner