note 57147 modified in ref.spl by helly

From: Date: Sun, 13 Aug 2006 11:11:23 +0000
Subject: note 57147 modified in ref.spl by helly
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115856@lists.php.net to get a copy of this message
There is a RecursiveFilterIterator that makes the above code much easier. And then ther is ParentIterator thta is already a filtering recursive iterator that only accepts elements that have children, with a RecursiveDirectoryIterator as inner iterator you would obviously get only the directories. Further more it ensures that it creates the correct children. All in all you simply need to do this: $it = new RecursiveDirectoryIterator($path); $it = new ParentIterator($it); $it = new RecursiveIteratorIteator($it); foreach($it as $dir => $o) { ... } --was-- There is a RecursiveFilterIterator that makes the above code much easier. And then ther is ParentIterator thta is already a filtering recursive iterator that only accepts elements that have children, with a RecursiveDirectoryIterator as inner iterator you would obviously get only the directories. Further more it ensures that it creates the correct children. All in all you simply need to do this: $it = RecursiveDirectoryIterator($path); $it = ParentIterator($it); $it = new RecursiveIteratorIteator($it); foreach($it as $dir => $o) { ... } http://php.net/manual/en/ref.spl.php

« previous php.notes (#115856) next »