\n"; while($file = $dirOb->read()){ if($file == "." || $file == ".."){"/> \n"; while($file = $dirOb->read()){ if($file == "." || $file == ".."){">

Home >Backend Development >PHP Tutorial >Recursively traverse all file instance codes directly

Recursively traverse all file instance codes directly

零下一度
零下一度Original
2017-07-02 09:47:531047browse
<?php  
  
//直接遍历所有文件.递归  function trees($dirname){  $dirOb = dir($dirname);  
     echo "<ul>\n";  while($file = $dirOb->read()){  if($file == "." || $file == ".."){  
              
        }else{  if(is_dir("$dirname/$file")){  echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>\n";  
                trees("$dirname/$file");  
            }else{  
                 echo "<li>$file</li>\n";  
            }  
        }  echo "<br/>";  
    }  echo "</ul>\n";  
}  
trees("../tp5");

The above is the detailed content of Recursively traverse all file instance codes directly. For more information, please follow other related articles on the PHP Chinese website!

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