note 127121 deleted from function.array-merge by cmb
| From: | cmb@php.net | Date: | Sat, 21 May 2022 09:20:51 +0000 |
| Subject: | note 127121 deleted from function.array-merge by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218511@lists.php.net to get a copy of this message | ||
Note Submitter: Maks
----
Be careful with the return value.
In the "Return Values" section it states the next:
> Returns the resulting array. If called without any arguments, returns an empty array.
By that, we can assume that the result of the function is ALWAYS an array, as there are no other
statements.
Indeed, when one of the values is not an array and the PHP version is < 8.0, it can be NULL and
the "Warning" will be generated. With PHP >= 8.0 it will be a "Fatal error".
<?PHP
foreach ([null, false, ''] as $item) {
$list = array_merge($item, [1, 2]);
echo null === $list ? 'YES' : 'NO'; // It's always YES here
}
?>