从指定目录中提取所有图像,然后显示它们 [英] Pull all images from a specified directory and then display them

查看:88
本文介绍了从指定目录中提取所有图像,然后显示它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示指定目录中的图像?就像我想显示目录中的所有png图像一样,在我的情况下,我的目录是media/images/iconized.

How to display the image from a specified directory? like i want to display all the png images from a directory, in my case my directory is media/images/iconized.

我试图环顾四周,但似乎它们都不符合我的真正需求.

I tried to look around but seems none of them fits what i really needed.

但这是我的尝试.

$dirname = "media/images/iconized/";
$images = scandir($dirname);
$ignore = Array(".", "..");
foreach($images as $curimg){
if(!in_array($curimg, $ignore)) {
echo "<img src='media/images/iconized/$curimg' /><br>\n";
};
}

希望这里有人可以帮助您.我对任何想法,建议和建议都持开放态度,谢谢.

hope someone here could help. Im open in any ideas, recommendation and suggestion, thank you.

推荐答案

您也可以为此使用glob:

$dirname = "media/images/iconized/";
$images = glob($dirname."*.png");

foreach($images as $image) {
    echo '<img src="'.$image.'" /><br />';
}

这篇关于从指定目录中提取所有图像,然后显示它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆