RecursiveDirectoryIterator class
<?php
$rootDir = 'test_dir';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootDir));
$files = [];
foreach ($it as $file) {
if ($file->isFile()) {
$files[] = $file->getPathname();
}
}
print_r($files);
Leave a Comment
Cancel reply