我正在尝试获取订阅者ID的值但我在第3个foreach上获得了php错误。
$content = '{"12345":{"id":"123","data":{"sort":"desc","subcriber":{"id":321"}}}';
$json = json_decode($content, true);
foreach($json as $row => $val) {
echo $val['id'];
$jdata = $val['data'];
foreach($jdata as $data => $val2) {
echo $val2['sort'];
$jsubcriber = $val2['subcriber'];
foreach($jsubcriber as $subcriber => $val3) {
echo $val3['id'];
}
}
}
答案 0 :(得分:0)
应该是:
echo $jsubscriber['id'];
$jsubscriber
是一个关联数组,而不是关联数组的数组。