开发者

How to add a imagejudgement in json decode foreach

How to add a imagejudgement in json decode foreach. if there is a jpg,png,gif in the end, so that echo html_entity_decode($result->url), else not. thanks.

foreach ($data->query->allimages as $result) {
ec开发者_StackOverflowho '<img src="'.html_entity_decode($result->url).'" /><br/>';
}


So please try this:

foreach ($data->query->allimages as $result) {
    $path = pathinfo($result->url);
    if(!in_array($path['extension'], array('jpg','png','gif'))) continue;
    echo '<img src="'.html_entity_decode($result->url).'" /><br/>'."\n";
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜