[英]Loop through 5 dimensional array in PHP
我有一個 json 響應作為數組
$responseArray['business_discovery']['media']['data'][0]['id']
我正在嘗試遍歷“數據”元素並獲取“id”的值並將其放入一個數組中,例如
$idarray[0] = $responseArray['business_discovery']['media']['data'][0]['id']
下一次迭代
$idarray[1] = $responseArray['business_discovery']['media']['data'][1]['id']
完成此任務的最佳循環是什么?
您應該能夠將data
設置為變量並循環遍歷該變量。
$data = $responseArray['business_discovery']['media']['data'];
foreach($data as $item) {
// do something with the id
$thisId = $item['id']
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.