把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); }