note 123566 added to function.array-merge
| From: | chris at 3rcinteractive dot com | Date: | Wed, 30 Jan 2019 15:24:02 +0000 |
| Subject: | note 123566 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210142@lists.php.net to get a copy of this message | ||
Something I ran across that may be useful to some. If one of the parameters in the merge is NOT an
array you won't receive a notice that type is incorrect. Instead the merged array will nullify.
<?php
$first = 'foo';
$second = ['bar', 'again'];
$merged = array_merge($first, $second);
var_dump($merged);
// will display null
?>
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.35 (proxied: 96.71.17.137)
----
Manual Page -- http://php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/123566
Del: integrated -- https://master.php.net/note/delete/123566/integrated
Del: useless -- https://master.php.net/note/delete/123566/useless
Del: bad code -- https://master.php.net/note/delete/123566/bad+code
Del: spam -- https://master.php.net/note/delete/123566/spam
Del: non-english -- https://master.php.net/note/delete/123566/non-english
Del: in docs -- https://master.php.net/note/delete/123566/in+docs
Del: other reasons-- https://master.php.net/note/delete/123566
Reject -- https://master.php.net/note/reject/123566
Search -- https://master.php.net/manage/user-notes.php