Home  >  Article  >  Backend Development  >  Wrote a method to traverse directories_PHP tutorial

Wrote a method to traverse directories_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:39:10741browse

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486326.htmlTechArticlefunction traversal($dirname) { $dir = dirname($dirname); if(!is_dir($dirname)){ die(Bad path please retry!!!); return ; } $handle = opendir($dirname); while(($file=readdir($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