1
如何显示子文件夹中的所有图像,如下所示:$ dir = array('images/posters','images/designs','images/illustrations'); ??php在文件夹和子文件夹中显示图像
代码:
<?php
$dir = 'img/werk/';
$file_display = array('jpg', 'jpeg', 'png', 'gif');
if (file_exists($dir) == false) {
echo 'Directory \'', $dir, '\' not found!';
} else {
$dir_content = scandir($dir);
foreach ($dir_content as $file) {
$file_type = strtolower(end(explode('.', $file)));
if ($file !== '.' && $file !== '..'
&& in_array($file_type, $file_display) == true) {
echo '<div class="thing large"><div class="item_description">Item description</div><img src="', $dir, '/', $file, '" /></div>';
}
}
}
?>
非常感谢,这是很好的代码,但我已经解决了它与解决方法:)爱这个论坛 – Auguste