解决php json_encode 出现的中文转码、乱码问题
// 防止json中文转码function jsonEncodeWithCN($data) {
return preg_replace("/\\\u({4})/ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '$1'))", json_encode($data));
}
$arr = array('a'=>'测试', b=>'hello');
echo jsonEncodeWithCN($arr);
页:
[1]