我在从 JSON 中创建 foreach 循环时遇到问题,我无法从数组中正确获取值,我做错了什么?
JSON:
[
{"Pages":{
"name":"Name 1",
"id":"3342939832994"
}
},
{"Pages":{
"name":"Name 2",
"id":"289051164453763"
}
}
]
PHP:
$json = $_POST['Publish'];
$json = $json->Pages
foreach($json as $key => $items) {
$id = $items->id;
$name = $items->id;
}