php生成指定路径下的目录结构,md文档格式
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。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');输出如下
