|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-10-25 21:57 UTC] tony2001@php.net
[2005-10-26 04:52 UTC] curt@php.net
[2005-10-28 11:58 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Description: ------------ array_walk_recursive() modifies element values deeper than the first level on vars outside the scope of the function call. Reproduce code: --------------- <?php $ar = array( 'element 1', array('element2 => subelement1') ); func($ar); var_dump($ar); function func($a) { array_walk_recursive($a, 'apply'); } function apply(&$input, $key) { $input = 'changed'; } Expected result: ---------------- array(2) { [0]=> string(9) "element 1" [1]=> array(1) { [0]=> string(23) "element2 => subelement1" } } Actual result: -------------- array(2) { [0]=> string(9) "element 1" [1]=> array(1) { [0]=> string(7) "changed" } }