[PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
I have discovered that when I foreach over a RecursiveDirectoryIterator (see example below) the $item actually turns into a SplFileInfo object. I would expect it to be a RecursiveDirectoryIterator. How do I do a hasChildren() on SplFileInfo? However, if I change it to a non-recursive,

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Philip Graham
Here's a RecursiveDirectoryIterator class I've written and find quite useful: ?php /** * This class encapsulates an iterator that iterates over all the files in a * directory recursively. Only files that don't begin with a '.' are included * in this iteration. This class essentially wraps an

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Nathan Nobbe
On Mon, Feb 23, 2009 at 9:31 AM, Ryan Panning rpann...@gmail.com wrote: I have discovered that when I foreach over a RecursiveDirectoryIterator (see example below) the $item actually turns into a SplFileInfo object. I would expect it to be a RecursiveDirectoryIterator. How do I do a

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
Nathan Nobbe wrote: if youre trying to do recursive iteration whereby you 'flatten' the tree structure, drop the RecursiveDirectoryIterator into a RecursiveIteratorIterator (its for iterating over RecursiveIterators), then you dont have to bother w/ calling hasChildren() at all. you probly also

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
Philip Graham wrote: Here's a RecursiveDirectoryIterator class I've written and find quite useful: ?php /** * This class encapsulates an iterator that iterates over all the files in a * directory recursively. Only files that don't begin with a '.' are included * in this iteration. This

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Philip Graham
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

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Nathan Nobbe
On Mon, Feb 23, 2009 at 10:27 AM, Ryan Panning rpann...@gmail.com wrote: Nathan Nobbe wrote: if youre trying to do recursive iteration whereby you 'flatten' the tree structure, drop the RecursiveDirectoryIterator into a RecursiveIteratorIterator (its for iterating over RecursiveIterators),