PHP hex2bin() Function

PHP hex2bin() function is used to convert a string hexadecimal value to ASCII ccharacters.

Syntax:


string hex2bin ( string $data )  
     
Parameter Description Required/Optional
String Specify the hexadecimal value to be converted. Required

Example 1


<?php  
echo hex2bin("48656c6c6f20576f726c6421");  
?>
        

Output

Hello World!

Example 2


<?php  
$hex = hex2bin("6578616d706c65206865782064617461");  
var_dump($hex); 
?>
        

Output

string(16) "example hex data"