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";
}
加载中,请稍侯......
精彩评论