note 114554 added to recursivearrayiterator.getchildren

From: Date: Wed, 05 Mar 2014 20:44:41 +0000
Subject: note 114554 added to recursivearrayiterator.getchildren
Groups: php.notes 
Request: Send a blank email to php-notes+get-198806@lists.php.net to get a copy of this message
RecursiveArrayIterator::getChildrens returns a copy of the children, not a reference: <?php $stack = array ("some" => "value", array ("subsome" => "subvalue", array ("subsubsome" => "subsubvalue")), "some1" => "value1"); $object = new RecursiveArrayIterator ($stack); $object->next (); $second_object = &$object->getChildren (); $second_object->next (); $third_object = &$second_object->getChildren (); $third_object->offsetSet ("subsubsome", "subsubdiferent"); var_dump ($object); var_dump ($second_object); var_dump ($third_object); ?> returns: object(RecursiveArrayIterator)#1 (1) { ["storage":"ArrayIterator":private]=> array(3) { ["some"]=> string(5) "value" [0]=> array(2) { ["subsome"]=> string(8) "subvalue" [0]=> array(1) { ["subsubsome"]=> string(11) "subsubvalue" <--- expected to be changed } } ["some1"]=> string(6) "value1" } } object(RecursiveArrayIterator)#2 (1) { ["storage":"ArrayIterator":private]=> array(2) { ["subsome"]=> string(8) "subvalue" [0]=> array(1) { ["subsubsome"]=> string(11) "subsubvalue" <--- expected to be changed } } } object(RecursiveArrayIterator)#3 (1) { ["storage":"ArrayIterator":private]=> array(1) { ["subsubsome"]=> string(14) "subsubdiferent" } } ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/recursivearrayiterator.getchildren.php Edit -- https://master.php.net/note/edit/114554 Del: integrated -- https://master.php.net/note/delete/114554/integrated Del: useless -- https://master.php.net/note/delete/114554/useless Del: bad code -- https://master.php.net/note/delete/114554/bad+code Del: spam -- https://master.php.net/note/delete/114554/spam Del: non-english -- https://master.php.net/note/delete/114554/non-english Del: in docs -- https://master.php.net/note/delete/114554/in+docs Del: other reasons-- https://master.php.net/note/delete/114554 Reject -- https://master.php.net/note/reject/114554 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198806) next »