php生成指定路径下的目录结构,md文档格式

来源:赵克立博客 分类: PHP 标签:php扩展发布时间:2020-01-12 15:18:48最后更新:2020-01-12 15:19:18浏览:567
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2020-01-12 15:19:18
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
$ignoreDir = ['.git', '.idea', 'vendor', '.vscode', 'logs', 'uploads', 'static', 'public'];
function loopDir($dir)
{
    global $ignoreDir;
    static $level = 0;
    $handle       = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $str = '';
            for ($i = 0; $i < $level; $i++) {
                $str .= '  ';
            }
            if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {

                if (!in_array($file, $ignoreDir)) {

                    echo $str . ($level > 0 ? '  - ' : '- ') . $file . PHP_EOL;
                    ++$level;
                    loopDir($dir . DIRECTORY_SEPARATOR . $file);
                }

            }
        }
    }
    $level--;
    closedir($handle);
}

loopDir('E:/GitServer/Ank');

输出如下

2001121578813556785818.png


微信号:kelicom QQ群:215861553 紧急求助须知
Win32/PHP/JS/Android/Python