递归返回所有目录


  1. function listFile($dir,$files=array()) {
  2.    $handle = opendir($dir) or return;
  3.    if(substr($dir,-1)==’/') $dir=substr($dir,0,-1);
  4.    while (false !== ($file = readdir($handle))) {
  5.     if((substr($file,0,1)!=’.') && is_dir($dir.’/’.$file))   $this->listFile($dir.’/’.$file,&$files);
  6.     else {
  7.      if(substr($file,0,1)==’.') continue;
  8.      $files[]=$dir.’/’.$file;
  9.     }
  10.       }
  11.       closedir($handle);
  12.       return $files;
  13.  }
  1. No comments yet.
(will not be published)
  1. No trackbacks yet.