ID: 45126 Updated by: [EMAIL PROTECTED] Reported By: mark at dynom dot nl -Status: Assigned +Status: Bogus Bug Type: Arrays related Operating System: * PHP Version: 5CVS, 6CVS (2008-11-21) Assigned To: tony2001 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to pass $result explicitly as reference. If you do not, array_walk_recursive uses its own copy of the variable (this still allows it to pass its own copy as reference to the callback function). See other reports about array_walk(). Previous Comments: ------------------------------------------------------------------------ [2008-11-21 17:26:37] [EMAIL PROTECTED] revision 1.395 date: 2006/11/22 10:58:11; author: tony2001; state: Exp; lines: +3 -3 fix #39576 (array_walk() doesn't separate userdata zval) ------------------------------------------------------------------------ [2008-11-21 17:24:13] [EMAIL PROTECTED] Seems to be related: bug #39576 (odd that the report talks about array_intersect though?) Tony, can you check this out? ------------------------------------------------------------------------ [2008-11-21 17:10:50] [EMAIL PROTECTED] Note: I fixed the typo in summary, this is about array_walk_recursive() (and propably array_walk() has same issue) ------------------------------------------------------------------------ [2008-05-29 10:55:26] mark at dynom dot nl 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) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45126&edit=1