首页 > 代码库 > php输出json中文显示编码-解决办法

php输出json中文显示编码-解决办法

$str = "中华人民共和国";
$ar = array(
"a" => "a0",
"b" => "b0",
"c" => "c0",
"d" => "d0",
"e" => $str,
);
echo preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv(‘UCS-2BE‘, ‘UTF-8‘, pack(‘H4‘, ‘\\1‘))", json_encode($ar));