Computer >> Computer tutorials >  >> Programming >> PHP

hex2bin() function in PHP


The hex2bin() function is used to convert a string of hexadecimal to ASCII character.

Syntax

hex2bn(str)

Parameters

  • str − The hexadecimal value to be converted

Return

The hex2bin() function returns the ASCII character of the converted string, or FALSE on failure.

Example

The following is an example −

<?php
   echo hex2bin("6578616d706c65206865782064617461");
?>

Output

example hex data