#11074 [Com]: array_splice used to insert associative array forgets first key

From: Date: Tue, 20 Jul 2004 15:04:33 +0000
Subject: #11074 [Com]: array_splice used to insert associative array forgets first key
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-62917@lists.php.net to get a copy of this message
ID: 11074 Comment by: sex-porn1342 at hotmail dot com Reported By: symetrie at online dot fr Status: Bogus Bug Type: Arrays related Operating System: Linux SuSE 6.4 PHP Version: 4.0.4pl1 New Comment: <a href=http://a-pinkorgy-fisting.da.ru>sex porn</a> Previous Comments: ------------------------------------------------------------------------ [2002-02-26 21:37:46] yohgaki@php.net The version of PHP that this bug was reported in is too old. Please try to reproduce this bug in the latest version of PHP (available from http://www.php.net/downloads.php If you are still able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". ------------------------------------------------------------------------ [2001-05-23 22:04:42] symetrie at online dot fr It seems to be impossible to replace a key in associative array with another array : array_splice always add a '0' key... Feature or bug ? <?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 ) echo "<hr>"; // 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 ) // I'd like : // Array ( [a] => AA [z] => Array ( [z1] => ZZ1 [z2] => ZZ2 ) [1] => XX [c] => CC ) ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=11074&edit=1

« previous php.bugs (#62917) next »