可以使用完成json_decode()
,请确保将第二个参数设置为,true
因为您需要数组而不是对象。
$array = json_decode($json, true); // decode json
输出:
Array
(
[id] => 1
[name] => foo
[email] => foo@test.com
)
将JSON字符串内容解析为PHP数组
可以使用完成json_decode()
,请确保将第二个参数设置为,true
因为您需要数组而不是对象。
$array = json_decode($json, true); // decode json
输出:
Array
(
[id] => 1
[name] => foo
[email] => foo@test.com
)