|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-21 17:10 UTC] jani@php.net
[2008-11-21 17:24 UTC] jani@php.net
[2008-11-21 17:26 UTC] jani@php.net
[2008-11-26 01:24 UTC] lbarnaud@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 21:00:01 2025 UTC |
Description: ------------ Only old-style call pass by reference works with array_merge_recursive, but the 'new' way doesn't Reproduce code: --------------- <?php $ar = array('a'=>array(1,5,9,12=>array(1,3,5,200)), 1,3,100, 100=>array(1,9,50)); //--- ONE ------------------------------------ $result_one = array(); array_walk_recursive($ar, 'walker_one', $result_one); function walker_one($v, $k, &$result) { $result[ $v ] = $v; } //--- TWO ------------------------------------ $result_two = array(); array_walk_recursive($ar, 'walker_two', &$result_two); function walker_two($v, $k, $result) { $result[ $v ] = $v; } var_dump($result_one, $result_two); Expected result: ---------------- array(7) { [1]=> int(1) [5]=> int(5) [9]=> int(9) [3]=> int(3) [200]=> int(200) [100]=> int(100) [50]=> int(50) } array(7) { [1]=> int(1) [5]=> int(5) [9]=> int(9) [3]=> int(3) [200]=> int(200) [100]=> int(100) [50]=> int(50) } Actual result: -------------- array(0) { } array(7) { [1]=> int(1) [5]=> int(5) [9]=> int(9) [3]=> int(3) [200]=> int(200) [100]=> int(100) [50]=> int(50) }