ID: 42654 Updated by: [EMAIL PROTECTED] Reported By: ltaupiac at lfdj dot com -Status: Assigned +Status: Closed Bug Type: SPL related Operating System: windows PHP Version: 5CVS-2007-09-13 (snap) Assigned To: helly New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-09-13 09:51:36] [EMAIL PROTECTED] Assigned to the SPL maintainer. ------------------------------------------------------------------------ [2007-09-13 09:48:31] ltaupiac at lfdj dot com Description: ------------ when recursively iterate over recursive array to alter leaves, only first leaves are altered. Reproduce code: --------------- $data = array ('key1' => 'val1', array('key2' => 'val2'), 'key3' => 'val3'); $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data)); foreach($iterator as $foo) { $key = $iterator->key(); switch($key) { case 'key1': // first level case 'key2': // recursive level echo "update $key<br>"; $iterator->offsetSet($key, 'alter'); } } $copy = $iterator->getArrayCopy(); var_dump($copy); Expected result: ---------------- update key1 update key2 array(3) { ["key1"]=> string(5) "alter" [0]=> array(1) { ["key2"]=> string(4) "alter" } ["key3"]=> string(4) "val3" } Actual result: -------------- update key1 update key2 array(3) { ["key1"]=> string(5) "alter" [0]=> array(1) { ["key2"]=> string(4) "val2" } ["key3"]=> string(4) "val3" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42654&edit=1