How to convert hex to string or text in php

风流意气都作罢 提交于 2019-12-06 07:37:59
  function hex2str($hex) {
    for($i=0;$i<strlen($hex);$i+=2)
       $str .= chr(hexdec(substr($hex,$i,2)));

    return $str;
  }

Will do the trick

Try this function

function hex2str($func_string) {
$func_retVal = '';
$func_length = strlen($func_string);
for($func_index = 0; $func_index < $func_length; ++$func_index) $func_retVal .= chr(hexdec($func_string{$func_index} . $func_string{++$func_index}));

return $func_retVal;
}

I use this one a lot personally so it should work.

You can try

hex2bin()

That'll convert your hex to a string format.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!