String Function
Execute String Function Online
String Functions Online Tool

Php Hex to String Tutorial


hexdec() - Hex to String Tutorial

The php string function hexdec() converts a hex into a number.

number hexdec ( string $hex_string )

In order to convert a hex value into a string, you need the following function. There are no php function designed to convert a hexadecimal to string.

function hextostr($hex)
for ($i=0; $i < strlen($hex)-1; $i+=2)
$str .= chr(hexdec($hex[$i].$hex[$i+1]));
return $str;

The $hex parameter is a string which represent a hex value.
It returns a string which is the string converted.


Php Hex to String Example

Example: We have the hex "48654c4c6f20576f526c4421"
The php hex to string function returns the value "HeLLo WoRlD!". This is the string value that has been converted from the hex "48654c4c6f20576f526c4421"

Test it online using our Hex-to-String Tool