Bug #11074 Updated: array_splice used to insert associative array forgets first key

From: Date: Wed, 27 Feb 2002 02:37:46 +0000
Subject: Bug #11074 Updated: array_splice used to insert associative array forgets first key
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1136@lists.php.net to get a copy of this message
ID: 11074 Updated by: yohgaki@php.net Reported By: symetrie@online.fr -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux SuSE 6.4 PHP Version: 4.0.4pl1 New Comment: 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". Previous Comments: ------------------------------------------------------------------------ [2001-05-23 22:04:42] symetrie@online.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 (#1136) next »