note 82306 added to function.array-merge

From: Date: Fri, 04 Apr 2008 22:02:26 +0000
Subject: note 82306 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-137941@lists.php.net to get a copy of this message
The documentation is a touch misleading when it says: "If only one array is given and the array is numerically indexed, the keys get reindexed in a continuous way." Even with two arrays, the resulting array is re-indexed: [bishop@predator staging]$ cat array_merge.php <?php $a = array (23 => 'Hello', '42' => 'World'); $a = array_merge(array (0 => 'I say, '), $a); var_dump($a); ?> [bishop@predator staging]$ php-5.2.5 array_merge.php array(3) { [0]=> string(7) "I say, " [1]=> string(5) "Hello" [2]=> string(5) "World" } [bishop@predator staging]$ php-4.4.7 array_merge.php array(3) { [0]=> string(7) "I say, " [1]=> string(5) "Hello" [2]=> string(5) "World" } ---- Server IP: 64.71.164.2 Probable Submitter: 24.148.133.105 ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- https://master.php.net/note/edit/82306 Del: integrated -- https://master.php.net/note/delete/82306/integrated Del: useless -- https://master.php.net/note/delete/82306/useless Del: bad code -- https://master.php.net/note/delete/82306/bad+code Del: spam -- https://master.php.net/note/delete/82306/spam Del: non-english -- https://master.php.net/note/delete/82306/non-english Del: in docs -- https://master.php.net/note/delete/82306/in+docs Del: other reasons-- https://master.php.net/note/delete/82306 Reject -- https://master.php.net/note/reject/82306 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137941) next »