<?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!