Re: RecursiveDirectoryIterator and foreach

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On February 23, 2009 12:32:26 Ryan Panning wrote:
> Hi, although I don't think this will work in my situation, there is an
> interesting piece of code that you have.
>
> array_push($this->_dirStack, $this->_curDirIter);
>
> Are you able to "inject" the iterator with more items? I would like to
> do this with the RecursiveDirectoryIterator where-by I "inject" fake
> files into the iterator. Is this what you're doing here?

Yes, in essence that is what this is doing but I am not manipulating the 
DirectoryIterator objects.  I am instead using my own structure and logic to 
do this.

Basically I'm using normal (i.e flat) DirectoryIterator objects but when I 
encounter a sub directory, I instantiate another DirectoryIterator for the 
sub-directory to continue the iteration.  In order to remember where I was 
once I've finished iterating over the sub-directory the current iterator is 
pushed onto a stack.  Then once the iteration of the sub-directory is finished 
the iterator for the parent directory is popped off the stack and the 
iteration over that directory continues from where it was interrupted.

Does this explanation satisfy your question?


-- 
Philip Graham
Lightbox Technologies
Suite 312 240 Catherine St.
Ottawa, ON, K2P 2G8
613-686-1661 ext. 102

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux