- dir: documentation ( source)
- is_dir: documentation ( source)
<?php
function rec($dir, $depth) {
$d = dir($dir);
while ($entry = $d->read()) {
if ($entry == '.' || $entry == '..') continue;
echo $depth . $entry . "\n";
if (is_dir($dir . '/' . $entry)) {
rec($dir . '/' . $entry, $depth . " ");
}
}
}
rec('/', '');