note 98973 added to function.array-merge
| From: | daevid at daevid dot com | Date: | Mon, 19 Jul 2010 19:26:52 +0000 |
| Subject: | note 98973 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170977@lists.php.net to get a copy of this message | ||
<?php
$data = array(1,2,3,4,5);
$lame = null;
// note that if you pass in null, you will null your whole array!! LAME!
$foo = array_merge($data, $lame);
var_dump($foo);
$foo = array_merge($lame, $data);
var_dump($foo);
// you must cast your values as an array to get the desired results.
$foo = array_merge($data, (array)$lame);
var_dump($foo);
?>
----
Server IP: 192.41.42.26
Probable Submitter: 206.169.197.253
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/98973
Del: integrated -- https://master.php.net/note/delete/98973/integrated
Del: useless -- https://master.php.net/note/delete/98973/useless
Del: bad code -- https://master.php.net/note/delete/98973/bad+code
Del: spam -- https://master.php.net/note/delete/98973/spam
Del: non-english -- https://master.php.net/note/delete/98973/non-english
Del: in docs -- https://master.php.net/note/delete/98973/in+docs
Del: other reasons-- https://master.php.net/note/delete/98973
Reject -- https://master.php.net/note/reject/98973
Search -- https://master.php.net/manage/user-notes.php