note 126067 deleted from function.array-filter by cmb
| From: | cmb@php.net | Date: | Mon, 10 May 2021 17:05:15 +0000 |
| Subject: | note 126067 deleted from function.array-filter by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216368@lists.php.net to get a copy of this message | ||
Note Submitter: Emilio_Bravo
----
<?php
class ArrayEvaluator
{
public static function null_by_false(array &$array)
{
$array = array_map(fn($key) => $key ?? false, $array);
}
}
$array = ['a',null,'b',null];
ArrayEvaluator::null_by_false($array);
var_dump($array);
/*Output*/
/*
array(4) {
[0]=>
string(1) "a"
[1]=>
bool(false)
[2]=>
string(1) "b"
[3]=>
bool(false)
}
*/