开发者

How to add a imagejudgement in json decode foreach

开发者 https://www.devze.com 2023-02-07 19:22 出处:网络
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.

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

精彩评论

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