1 // 防止json中文转码2 function jsonEncodeWithCN($data) {3 return preg_replace("/\u([0-9a-f]{4})/ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '$1'))", json_encode($data));4 }5 6 $arr = array('a'=>'测试', b=>'hello');7 8 echo jsonEncodeWithCN($arr);
解决phpjson_encode出现