Skip to content

Instantly share code, notes, and snippets.

@eddy8
Created June 5, 2013 01:57
Show Gist options
  • Save eddy8/5711107 to your computer and use it in GitHub Desktop.
Save eddy8/5711107 to your computer and use it in GitHub Desktop.
16进制串转字符串
<?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