for(int $i=0; $i<count($lists["item_collection"]["entries"]); $i++){
foreach($lists['item_collection']['entries'] as $list)
{
$print['file_name'] = $list[$i]['name'];
$print['file_id'] = $list[$i]['id'];
$print['file_type'] = $list[$i]['type'];
array_push($content,$print);
}
}
我正在尝试获取文件数组的名称,类型,ID但我只得到第一个所以我试图循环它但它不起作用。我这样做对吗?
我没有测试它
foreach($lists["item_collection"]["entries"] as $v){
foreach($v as $val){
$print['file_name'] = $val['name'];
$print['file_id'] = $val['id'];
$print['file_type'] = $val['type'];
array_push($content,$print);
}
}
无需在 for 循环中执行此操作,只需:
foreach($lists["item_collection"]["entries"] as $key => $val){
$print['file_name'] = $val['name'];
$print['file_id'] = $val['id'];
$print['file_type'] = $val['type'];
array_push($content,$print);
}