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),
>> then
>> you dont have to bother w/ calling hasChildren() at all.  you probly also
>> want to look at the constructor args, since by default, it only returns
>> leaf
>> nodes.
>>
>> $dir = new RecursiveDirectoryIterator('/path/to/dir');
>>
>> $itt = new RecursiveIteratorIterator($dir,
>> RecursiveIteratorIterator::CHILD_FIRST);
>>
>>  foreach ($itt as $item) {
>>>   print get_class($item) . "\r\n";
>>> }
>>>
>>
>>
>> -nathan
>
>
im not sure i fully understand the problem, but from the sound of it, as a
work-around, why not something like this,

$dirIt = new RecursiveDirectoryIterator($path);
foreach($dirIt as $item) {
  if($item->isDir()) {
    $subdir = new RecursiveDirectoryIterator($item);
    // now you have the RecursiveDirectoryIterator you wanted ??
  }
}

-nathan

Reply via email to