I’m trying to get the behavior like the “tree” command on linux or unix systems where the function returns a list or array of directories in its full path.
Example
~/
~/Pictures
~/Movies
~/Downloads
~/Documents
~/Documents/work
~/Documents/important
~/Documents/bills
~/Music
~/Music/80s/
etc …. etc…
Update #1:
If you want empty directories to be listed as well, use RecursiveIteratorIterator::CHILD_FIRST