Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取文件夹中的所有文件夹和图像列表_Php - Fatal编程技术网

Php 获取文件夹中的所有文件夹和图像列表

Php 获取文件夹中的所有文件夹和图像列表,php,Php,库文件夹中的目录是动态创建的。我正在尝试访问其中的文件夹和相应的图像。根据,现在我访问了文件夹,但没有在其中获取图像。如何循环与目录对应的所有图像。 请帮我解决这个问题 <?php #default directory $dir = '../gallery/'; $files1 = scandir($dir); #open a gallery directory if ($handle = opendir($dir)) { #read all the directories i

库文件夹中的目录是动态创建的。我正在尝试访问其中的文件夹和相应的图像。根据,现在我访问了文件夹,但没有在其中获取图像。如何循环与目录对应的所有图像。 请帮我解决这个问题

 <?php
#default directory
$dir    = '../gallery/';
$files1 = scandir($dir);

#open a gallery directory 
if ($handle = opendir($dir)) {
#read all the directories inside a gallery folder
        while($file = readdir($handle)){

                        if($file !== '.' && $file !== '..'){
#get all images inside variable $file                           
                            echo '<img src="../gallery/'.$file.'/" border="0" height="100" width="150"/>';

                }    
        }


}

?>

foreach(glob(“../gallery/”“*”)作为$filename){
回声';
}

Why not
glob()
是的,我尝试过,但无法循环。在这里,我只能检索文件夹,但无法检索其中的图像。路径正确。这是我正在运行的项目。gallery文件夹在test123中
foreach(glob("../gallery/".'*') as $filename) {
    echo '<img src="../gallery/'.basename($filename).'/" border="0" height="100" width="150"/>';
}