From: conciseusa at yahoo dot com
Operating system: Linux
PHP version: 4.3.8
PHP Bug Type: Arrays related
Bug description: array_splice discards keys of incoming array
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 bug report at http://bugs.php.net/?id=30305&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30305&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30305&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30305&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30305&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30305&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30305&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30305&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30305&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30305&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30305&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30305&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30305&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30305&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30305&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30305&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30305&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30305&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30305&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30305&r=mysqlcfg