Json_decode ()
$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;
The return value is null because the values of city and province are special characters. how can this problem be solved?
Reply to discussion (solution)
Conversion of special symbols
The city and province garbled characters should be solved first, and then json_decode, because in the manual, json_decode must be UTF-8 encoded. Try iconv functions.
The city and province garbled characters should be solved first, and then json_decode, because in the manual, json_decode must be UTF-8 encoded. Try iconv functions.
Iconv tried. no.
City = Shenzhen
Province = Guangdong
$vvv = iconv('ucs-2', 'utf-8', $vvv);var_dump(json_decode($vvv,true));
It should be noted that your $ vvv must be the data from the original channel, rather than the copied and pasted data you posted.
The original unicode data cannot be restored after being copied and pasted.
"City": "mñw3", "province": "^ N
If there is data that is not utf8, it must be processed first.
City = Shenzhen
Province = Guangdong
$vvv = iconv('ucs-2', 'utf-8', $vvv);var_dump(json_decode($vvv,true));
It should be noted that your $ vvv must be the data from the original channel, rather than the copied and pasted data you posted.
The original unicode data cannot be restored after being copied and pasted.
No, I got this data from the interface. I have not processed json_decode, but some of the information is indeed garbled.