|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-23 15:33 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 18:00:02 2025 UTC |
Description: ------------ 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. <?php $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. <?php $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.