PHP Recursively list directories and files; recursive listing scan and traversal

PHP List directory files and folders.

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
 
header('Content-Type: text/plain');
 
$dir = dirname(__FILE__);
 
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $item) {
    if ($item->isFile() || $item->isDir()) {
        echo $item . PHP_EOL;
    }
}
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment