note 104899 added to class.recursivefilteriterator
| From: | arthur dot techarts at gmail dot com | Date: | Thu, 14 Jul 2011 14:41:51 +0000 |
| Subject: | note 104899 added to class.recursivefilteriterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181500@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 193.200.32.160
----
Manual Page -- http://www.php.net/manual/en/class.recursivefilteriterator.php
Edit -- https://master.php.net/note/edit/104899
Del: integrated -- https://master.php.net/note/delete/104899/integrated
Del: useless -- https://master.php.net/note/delete/104899/useless
Del: bad code -- https://master.php.net/note/delete/104899/bad+code
Del: spam -- https://master.php.net/note/delete/104899/spam
Del: non-english -- https://master.php.net/note/delete/104899/non-english
Del: in docs -- https://master.php.net/note/delete/104899/in+docs
Del: other reasons-- https://master.php.net/note/delete/104899
Reject -- https://master.php.net/note/reject/104899
Search -- https://master.php.net/manage/user-notes.php