|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34615 RecursiveDirectoryIterator is not recursive
Submitted: 2005-09-23 15:30 UTC Modified: 2005-09-23 15:33 UTC
From: richard dot quadling at bandvulc dot co dot uk Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.0.5 OS: Windows
Private report: No CVE-ID: None
 [2005-09-23 15:30 UTC] richard dot quadling at bandvulc dot co dot uk
Hopefully, my simple brain can explain this properly.

I want to use the RecursiveDirectoryIterator class.

Iterator = get "elements" from a "list", one at a time.
Directory = a "list" of files and directories (and links for those *ix bods).
Recursion = Repeat until complete on any "element" which contains a "list".

So, DirectoryIterator should return a list of files/directories for a single directory.

Which it does.

$objDI = new DirectoryIterator("C:/");
foreach($objDI as $key => $value)
	echo "$key $value\n";

produces a list of all the files and directories in the root of my C:. Just like I would expect.

A RecursiveDirectoryIterator

So, in my limited understanding (OK, I'm being facetous - I've been fighting Crystal Reports all day, so please give me a break), by using the RecursiveDirectoryIterator, I would expect to get a list of all the files and directories and sub-directories from C:\ onwards, a complete treewalk.

$objRDI = new RecursiveDirectoryIterator("C:/");
foreach($objRDI as $key => $value)
	echo "$key\n";

But no.

All this does is print the same list as DirectoryIterator. Admittedly, the name is now a key and the value is an object, but how is this recursive?

Either proper documentation for RecursiveDirectoryIterator (what is it recursing?) or a change to the name as it is NOT recursing is appropriate.

I've read the documentation at Helly, but it makes no sense as there no examples. It looks like I have to implement the recursion myself, so what does the class recurse?

Hopefully you can see my problem.

Richard Quadling.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-23 15:33 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

You need a RevursiveIteratorIterator. Have a look at or Marcus\' 
slides at 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri May 24 23:01:26 2019 UTC