Home >Backend Development >PHP Tutorial >php traverses sub-files under a folder

php traverses sub-files under a folder

巴扎黑
巴扎黑Original
2016-11-10 13:32:301139browse

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;
}
}
}


Statement:
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