Created
June 5, 2013 01:57
-
-
Save eddy8/5711107 to your computer and use it in GitHub Desktop.
16进制串转字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!function_exists('hex2bin')) { | |
/** | |
* 16进制串转字符串 | |
* @param {string} $h 16进制串 | |
* @return {string} 对应字符串,参数有误返回NULL | |
*/ | |
function hex2bin($h){ | |
if (!is_string($h)) return null; | |
$r=''; | |
for ($a=0; $a<strlen($h); $a+=2) { | |
$r.=chr(hexdec($h{$a}.$h{($a+1)})); | |
} | |
return $r; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment