首页 > 编程 > PHP > 正文

解决php json_encode 出现的中文转码、乱码问题

2019-11-15 01:31:48
字体:
来源:转载
供稿:网友
解决php json_encode 出现的中文转码、乱码问题
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);


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表