PHP Hex2bin () function


Note . The purpose of this function is - do not convert hexadecimal to binary, for this we can use base_convert() function in PHP. This function is simply used to decode a hex encoded binary string.Syntax:
string hex2bin ($hexString)  Parameters : This function takes one parameter, $hexString, which represents the hexadecimal data to be decoded into binary.Return Value:This function returns a string that is the binary representation of the hexadecimal input of $hexString. If this function fails to decode a hex string to binary, it returns False.Examples :
Input: $hexString = "48656c6c6f20576f726c6421" Output: Hello World! Input: $hexString = "6578616d706c65206865782064617461" Output: example hex data
The programs below illustrate the hex2bin() function:Program 1: echo hex2bin ( "48656c6c6f20576f726c6421" );  
Hello World!
Program 2: echo hex2bin ( "6578616d706c65206865782064617461" );  
example hex data
Link : manual / en / function.hex2bin.php

Get Solution for free from DataCamp guru