Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取值数组中的下一项_Php_Arrays_Foreach - Fatal编程技术网

Php 获取值数组中的下一项

Php 获取值数组中的下一项,php,arrays,foreach,Php,Arrays,Foreach,我试图从json文件中获取所有输出。到目前为止,我已经: $json_feed = file_get_contents($indy_feed_url); $json_items = json_decode($json_feed, TRUE); $individual = $json_items['indy'][0]; 然后呼应出来 这适用于项目0。但是,我想做所有的事情 json文件中的项目数量会随着时间的推移而变化,所以我不能在这里输入10个,因为有时可能会有20个或5个等等 如何在循环中

我试图从json文件中获取所有输出。到目前为止,我已经:

$json_feed = file_get_contents($indy_feed_url);
$json_items = json_decode($json_feed, TRUE);

$individual = $json_items['indy'][0];
然后呼应出来

这适用于项目0。但是,我想做所有的事情

json文件中的项目数量会随着时间的推移而变化,所以我不能在这里输入10个,因为有时可能会有20个或5个等等

如何在循环中执行此操作,以便它计算多次的项目和循环数?

使用以下语句:

foreach($json_items['indy'] as $item) {
    // do whatever you want with $item
}
使用以下语句:

foreach($json_items['indy'] as $item) {
    // do whatever you want with $item
}