How can I retrieve the full directory tree using SPL?
By default, the RecursiveIteratorIterator will use LEAVES_ONLY for the second argument to __construct. This means it will return files only. If you want to include files and directories (at least that’s what I’d consider a full directory tree), you’d have to do: $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST ); and then you can foreach … Read more