ID: 45126
Updated by: [EMAIL PROTECTED]
Reported By: mark at dynom dot nl
-Status: Open
+Status: Verified
Bug Type: Arrays related
Operating System: *
-PHP Version: 5.2.6
+PHP Version: 5CVS, 6CVS (2008-11-21)
New Comment:
Note: I fixed the typo in summary, this is about array_walk_recursive()
(and propably array_walk() has same issue)
Previous Comments:
------------------------------------------------------------------------
[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