From: mark at dynom dot nl
Operating system:
PHP version: 5.2.6
PHP Bug Type: Arrays related
Bug description: array_merge_recursive reference
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 bug report at http://bugs.php.net/?id=45126&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45126&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45126&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45126&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45126&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45126&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45126&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45126&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45126&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45126&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45126&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45126&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45126&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45126&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45126&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45126&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45126&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45126&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45126&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45126&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45126&r=mysqlcfg