I was thinking of using RecursiveIteratorIterator to display the “top-directories”, in my example layout and puffar, but I cannot get it to work. The structure is as follows:
| images |
=> layout
=>lab
=> puffar
and the result is
layout
layout
layout
layout/lab
layout/lab
puffar
puffar
$directory = 'images';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
while($it->valid()) {
if (!$it->isDot()) {
echo $it->getSubPath() . "\n";
}
$it->next();
}
another thing that I cannot get to work is if I change the directory path to
$directory = 'newsletter.site.se/images';
it is not displaying anything.
It would be fantasic if someone could help me. thanks linda
Do you really need
RecursiveDirectoryIteratorif you just want to display the top directories?Instead you could use:
If you want all directories, try: (for example)
About your second question, have you checked that the path is correct and readable for php?