php 目录递归函数-列出所文件与目录
<?php //用来实现我的需求。函数的原理很简单,主要就是用了一下递归调用。 //这个函数还可以继续做一些改进,加入一些文件夹或文件的图标什么的 function file_list($path) { if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($path . "/" . $file)) { //去掉此行显示的是所有的非目录文件 echo $path . ": " . $file . "<br>"; file_list($path . "/" . $file); } else { echo $path . ": " . $file . "<br>"; } } } } }
教程链接:http://www.phprm.com/code/php-dir.html
随意转载~但请保留教程地址★