note 104899 rejected from class.recursivefilteriterator by thiago

From: Date: Thu, 14 Jul 2011 16:52:48 +0000
Subject: note 104899 rejected from class.recursivefilteriterator by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181505@lists.php.net to get a copy of this message
Note Submitter: arthur dot techarts at gmail dot com ---- You can find few problems: when you use iterator_to_array function or getArrayCopy method, then RecursiveFilterIterator don't work proper. Example: $rIterator = new RecursiveArrayIterator( array( 'a', array( 'b', array( 'c', 'd', array('e') ) ), array('f') ) ); class Soglasnie extends RecursiveFilterIterator{ public static $FILTERS = array('a','e'); public function accept() { return !in_array($this->current(),self::$FILTERS); } } $a = new Soglasnie($rIterator); $b = new RecursiveIteratorIterator($a); foreach($b as $key => $value){ //it's ok echo $value . "\n"; } print_r(iterator_to_array($a)); //PROBLEM, FILTER JUST FIRST LEVEL print_r($b->getArrayCopy()); //PROBLEM, DON"T FILTER AT ALL

« previous php.notes (#181505) next »