note 49221 added to function.array-merge

From: Date: Thu, 20 Jan 2005 18:05:58 +0000
Subject: note 49221 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-83686@lists.php.net to get a copy of this message
Note that if you put a number as a key in an array, it is eventually converted to an int even if you cast it to a string or put it in quotes. That is: $arr["0"] = "Test"; var_dump( key($arr) ); will output int(0). This is important to note when merging because array_merge will append values with a clashing int-based index instead of replacing them. This kept me tied up for hours. ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49221 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49221&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49221&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49221&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49221&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49221&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49221&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83686) next »