Home  >  Article  >  php教程  >  写了个遍历目录的方法

写了个遍历目录的方法

WBOY
WBOYOriginal
2016-06-13 10:37:581045browse

function traversal($dirname)
{

$dir = dirname($dirname);
if(!is_dir($dirname)){
   die(Bad path please retry!!!);
   return ;
}

$handle = opendir($dirname);

while(($file=readdir($handle))!==false ){
   if($file != . && $file!=..){
    echo "
" ;
    echo $indir = $dirname . / . $file ;
    if(is_dir($indir)){
     allsee($indir);
    }
   }
 
}
closedir($handle);
}

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