Home > Backend Development > PHP Tutorial > Example of php traversing the directory output directory and all the files under it_PHP tutorial

Example of php traversing the directory output directory and all the files under it_PHP tutorial

WBOY
Release: 2016-07-13 10:39:48
Original
1099 people have browsed it

I have encountered this problem many times in written exams, so I wrote it out specially

Copy the code The code is as follows:

function my_scandir( $dir){
$files=array();
if(is_dir($dir)){
if($handle=opendir($dir)){
while(($file= readdir($handle))!==false){
if($file!='.' && $file!=".."){
if(is_dir($dir."/".$ file)){
$files[$file]=my_scandir($dir."/".$file);
}else{
$files[]=$dir."/".$file ;
}
}
}
}
}
closedir($handle);
return $files;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/728105.htmlTechArticleI have encountered this problem many times in written tests, so I specially wrote it and copied the code as follows: function my_scandir($ dir){ $files=array(); if(is_dir($dir)){ if($handle=opendir($dir...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template