0

I want to convert a "hex" String: $hexstring = "8F21FF434927";

into its ascii code: !ÿCI'

I found simple hex2str Methodes but they do an output like: 0x8F 0x21...

guenthernagel
  • 73
  • 1
  • 3
  • 14

1 Answers1

1
function hexToStr($hex){
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2){
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
}
echo hexToStr("8F21FF434927");
Sameer
  • 361
  • 1
  • 5