Im trying to display all the folders that are in a specific directory. Basically so each time a new folder is added, it will show up automatically on the list. Here is what i have so far. I have pieced this together from other posts and doesn’t seem to be working and not sure why. I get a nasty error about permissions and none found.
$dir = '/s/';
$result = array();
if (is_dir($dir)) {
$iterator = new RecursiveDirectoryIterator($dir);
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if (!$file->isFile()) {
$result[] = 'path: ' . $file->getPath(). ', filename: ' . $file->getFilename();
}
}
}
print_r($result);
You can use that home made code: