php - Is there any easy code to convert hex string into ascii? -
i have used 1 code converts hex ascii below:
<?php $convert = ''; function hexstr($hexstr) { $hexstr = str_replace(' ', '', $hexstr); $hexstr = str_replace('\x', '', $hexstr); $retstr = pack('h*', $hexstr); return $retstr; } $str2 = hexstr($convert); echo($str2); ?>
it works before shows ascii converted output shows error above like:
( ! ) warning: pack(): type h: illegal hex digit in c:\wamp\www\project\hextostring.php on line 8
why so? mean showing error , correct output? problem in code? line 8 is:
$retstr = pack('h*', $hexstr);
Comments
Post a Comment