note 126066 deleted from function.array-map by cmb
| From: | cmb@php.net | Date: | Mon, 10 May 2021 17:05:22 +0000 |
| Subject: | note 126066 deleted from function.array-map by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216367@lists.php.net to get a copy of this message | ||
Note Submitter: Emilio_Bravo
----
<?php
$array = [null,'a',null,'b',null,'c'];
$elements = array_map(fn($element) => $element = $element ?? false, $array);
var_dump($elements);
/*
Replaces null by false
Output:
array(6) {
[0]=>
bool(false)
[1]=>
string(1) "a"
[2]=>
bool(false)
[3]=>
string(1) "b"
[4]=>
bool(false)
[5]=>
string(1) "c"
}
*/