ID: 30305
Updated by: [EMAIL PROTECTED]
Reported By: conciseusa at yahoo dot com
-Status: Open
+Status: Verified
Bug Type: Arrays related
-Operating System: Linux
+Operating System: *
-PHP Version: 4.3.8
+PHP Version: 4CVS, 5CVS (20040929)
Previous Comments:
------------------------------------------------------------------------
[2004-10-01 18:20:59] conciseusa at yahoo dot com
Description:
------------
It seems to be impossible to replace a key in associative array with
another associative array : array_splice always add a '0' or next
unused numeric key for incoming array... This would seem to be a bug.
Reproduce code:
---------------
<?php
$a = array("a" => "AA", "b" => "BB", "c" => "CC");
$a2 = $a;
$z = array("z" => array("z1"=>"ZZ1","z2"=>"ZZ2"), "x" =>"XX");
// 1 try to replace "b"=>"BB" by contents of $z
array_splice($a, 1, 1, $z);
print_r($a);
// produces : Array ( [a] => AA [0] => Array ( [z1] => ZZ1 [z2] => ZZ2
)
[1] => XX [c] => CC )
// 2 try to replace "b"=>"BB" by contents of $z as in manual
array_splice($a, 1, 1, array($z));
print_r($a);
// produces: Array ( [a] => AA [0] => Array ( [z] => Array ( [z1] =>
ZZ1 [z2] => ZZ2 ) [x] => XX ) [1] => XX [c] => CC )
?>
Expected result:
----------------
// Should be :
// Array ( [a] => AA [z] => Array ( [z1] => ZZ1 [z2] => ZZ2 ) [1] =>
XX
[c] => CC )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30305&edit=1