开发者

Getting next item in an array of values

I'm trying to get every output out of a json file. So far I have:

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

$individual = $json_items['indy'][0];

and then echo things out.

This works fine for item 0. However, I want to do all items.

The number of items in the json file varies from time to time so I cannot just enter like 10 here because sometimes there might 开发者_开发技巧be 20 or 5 etc.

How can I do this in a loop so that it counts the number of items and loops that many times?


Use the foreach statement:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜