手记

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 {

                //这里做文件的操作

            }

        }

    }

}

0人推荐
随时随地看视频
慕课网APP