#20381 [Opn->Ver]: array_merge_recursive mangles input arrays
| From: | sniper@php.net | Date: | Tue, 12 Nov 2002 12:33:56 +0000 |
| Subject: | #20381 [Opn->Ver]: array_merge_recursive mangles input arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24689@lists.php.net to get a copy of this message | ||
ID: 20381
Updated by: sniper@php.net
Reported By: mailfrom-bugs.php.net@kopka.net
-Status: Open
+Status: Verified
Bug Type: Arrays related
Operating System: SuSE Linux 7.3
-PHP Version: 4.2.3
+PHP Version: 4.3.0-dev
New Comment:
Reproduced using latest CVS. The original arrays are fine, but when
they're added to the resulting array, then they get mangled.
Previous Comments:
------------------------------------------------------------------------
[2002-11-11 23:04:18] mailfrom-bugs.php.net@kopka.net
Similar to #14990 (exept that the demo code there runs fine) and the
first source array gets mangled.
Example
=========
<pre><?
$a = array(
'a1' => 1,
'a2' => array( 1, 2, 3 ),
'a3' => array(
'a' => array( 10, 20, 30 ),
'b' => 'b'
)
);
$b = array( 'a1' => 2,
'a2' => array( 3, 4, 5 ),
'a3' => array(
'c' => 'cc',
'a' => array( 10, 40 )
)
);
$c['result'] = array_merge_recursive( $a, $b );
$c['a'] = $a;
$c['b'] = $b;
print_r( $c );
?>
Example Output
================
Array
(
[result] => Array
(
[a1] => Array
(
[0] => 1
[1] => 2
)
[a2] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 3
[4] => 4
[5] => 5
)
[a3] => Array
(
[a] => Array
(
[0] => 10
[1] => 20
[2] => 30
[3] => 10
[4] => 40
)
[b] => b
[c] => cc
)
)
[a] => Array
(
[a1] => 1
[a2] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 3
[4] => 4
[5] => 5
)
[a3] => Array
(
[a] => Array
(
[0] => 10
[1] => 20
[2] => 30
[3] => 10
[4] => 40
)
[b] => b
[c] => cc
)
)
[b] => Array
(
[a1] => 2
[a2] => Array
(
[0] => 3
[1] => 4
[2] => 5
)
[a3] => Array
(
[c] => cc
[a] => Array
(
[0] => 10
[1] => 40
)
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20381&edit=1