mm111222 发表于 2018-12-15 07:08:19

php递归遍历目录

  其实很简单,就写了一个函数,没啥好说的直接上代码了
public function openDirectory($path)
{
    $dir = dir($path);
    while (false != ($entry = $dir->read())) {
      if ($entry != "." && $entry != "..") {
            if (is_dir($path . DIRECTORY_SEPARATOR . $entry)) {
                $this->openDirectory($path . DIRECTORY_SEPARATOR . $entry);
            } else {
                //这里做文件的操作
            }
      }
    }
}  




页: [1]
查看完整版本: php递归遍历目录