正常的是直接使用json_decode()即可。
$json ='[{"a":1,"b":2,"c":3,"d":4,"e":5},{"a":1,"b":2,"c":3,"d":4,"e":5}]'; $wwww=json_decode($json);
Array ( [0] => stdClass Object ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 ) [1] => stdClass Object ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 ) )
但是,我的问题是json_decode之后为空。
解决办法:$temp=stripslashes(html_entity_decode($temp));
html_entity_decode() 函数的作用是把 HTML 实体转换为字符。
stripslashes() 函数的作用是删除反斜杠。
因为我的json数组中有地址,带有/,所有要处理一下。