把16进制中文转为中文的函数
如
$str1 = '{"title":"\u8fd9\u91cc\u662f\u4e2d\u6587\u6807\u9898","body":"abcd..."}';
echo u2utf8($str1);
{"title":"这里是中文标题","body":"abcd..."}
function u2gbk($str){
return preg_replace("/\\\u([\da-f]{4})/ie", 'iconv("UCS-2BE","gb2312",pack("H4","\\1"))', $str);
}
function u2utf8($str){
return preg_replace("/\\\u([\da-f]{4})/ie", 'iconv("UCS-2BE","utf-8",pack("H4","\\1"))', $str);
}
转载于:https://blog.51cto.com/gavins/1274328