$vvv='{"subscribe":1,"openid":"ol2E7uLeDEi4VCBwrXI0KRwcvnyo","nickname":"xhm","sex":2,"language":"zh_CN","city":"mñW3","province":"^N","country":"","headimgurl":"http:\/\/wx.qlogo.cn\/mmopen\/PiajxSqBRaELiaLZZTltPhZobM3QcvGyGgRXnAlcPm8iaoWQWvuNuIFZk3kOOeNCQok1W4l6zashSAMfMSiasN4eZhbuib4NXuQNmQuFMn2XBd9M\/0","subscribe_time":1458906765,"remark":"","groupid":0}'; var_dump(json_decode($vvv,true));exit;
特殊符号进行转意
应该先解决city和province乱码的问题,再去json_decode,因为手册上说,json_decode必须是utf-8的编码格式。可以尝试用iconv相关函数试试
应该先解决city和province乱码的问题,再去json_decode,因为手册上说,json_decode必须是utf-8的编码格式。可以尝试用iconv相关函数试试
iconv试了,不行 city = 深圳
province = 广东
$vvv = iconv('ucs-2', 'utf-8', $vvv);var_dump(json_decode($vvv,true));
"city":"mñW3","province":"^N
有不是utf8的数据,需要先处理
city = 深圳
province = 广东
$vvv = iconv('ucs-2', 'utf-8', $vvv);var_dump(json_decode($vvv,true));