Php 如何在文件夹中显示文件夹中的所有照片?
我在开发一个简单的网站时遇到了一个问题。我想知道如何访问和显示存储在另一个文件夹中的文件夹中的所有图像?Php 如何在文件夹中显示文件夹中的所有照片?,php,html,image,loops,Php,Html,Image,Loops,我在开发一个简单的网站时遇到了一个问题。我想知道如何访问和显示存储在另一个文件夹中的文件夹中的所有图像? 感谢您的输入!=) 您可以使用scandir()函数读取文件夹中的所有文件,然后过滤这些文件并从主题中仅获取图像 <?php $folder = 'images'; $files = scandir($folder); $types = array('jpg','png','gif'); foreach($files as $file) { $exp = explode('.'
感谢您的输入!=) 您可以使用
scandir()
函数读取文件夹中的所有文件,然后过滤这些文件并从主题中仅获取图像
<?php
$folder = 'images';
$files = scandir($folder);
$types = array('jpg','png','gif');
foreach($files as $file) {
$exp = explode('.', $file);
$ex = end($exp);
if(in_array($ex , $types)) {
echo '<img src="'. $folder .'/'.$file.'" />';
}
}
?>
readdir
,scandir
等
$files = glob("images/*.jpg");