Files
php_8/iterators/recursion_dir.php
2022-08-05 09:50:27 +03:00

21 lines
427 B
PHP

<?php
function recursion_dir($path)
{
static $depth = 0;
$dir = opendir($path);
while (($file = readdir($dir)) !== false) {
if ($file == '.' || $file == '..' ) continue;
echo str_repeat('-', $depth)." $file<br />";
if (is_dir("$path/$file")) {
$depth++;
recursion_dir("$path/$file");
$depth--;
}
}
closedir($dir);
}
recursion_dir('.');