PHP中的5维数组循环
我有一个json响应作为数组PHP中的5维数组循环,php,loops,for-loop,foreach,while-loop,Php,Loops,For Loop,Foreach,While Loop,我有一个json响应作为数组 $responseArray['business_discovery']['media']['data'][0]['id'] 我试图循环遍历'data'元素,获取'id'的值,并将其放入一个数组中,如 $idarray[0] = $responseArray['business_discovery']['media']['data'][0]['id'] 下一次迭代 $idarray[1] = $responseArray['business_discover
$responseArray['business_discovery']['media']['data'][0]['id']
我试图循环遍历'data'元素,获取'id'的值,并将其放入一个数组中,如
$idarray[0] = $responseArray['business_discovery']['media']['data'][0]['id']
下一次迭代
$idarray[1] = $responseArray['business_discovery']['media']['data'][1]['id']
实现这一点的最佳循环是什么?您应该能够将
数据
设置为一个变量,并通过该变量进行循环
$data = $responseArray['business_discovery']['media']['data'];
foreach($data as $item) {
// do something with the id
$thisId = $item['id']
}