#20381 [NEW]: array_merge_recursive mangles input arrays

From: Date: Tue, 12 Nov 2002 05:04:18 +0000
Subject: #20381 [NEW]: array_merge_recursive mangles input arrays
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-24663@lists.php.net to get a copy of this message
From: mailfrom-bugs.php.net@kopka.net Operating system: SuSE Linux 7.3 PHP version: 4.2.3 PHP Bug Type: Arrays related Bug description: array_merge_recursive mangles input arrays 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 bug report at http://bugs.php.net/?id=20381&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20381&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20381&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20381&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20381&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20381&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20381&r=support Expected behavior: http://bugs.php.net/fix.php?id=20381&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20381&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20381&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20381&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20381&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20381&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20381&r=isapi

« previous php.bugs (#24663) next »