note 126067 added to function.array-filter
| From: | Emilio_Bravo at main dot php dot net | Date: | Mon, 10 May 2021 16:50:01 +0000 |
| Subject: | note 126067 added to function.array-filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216366@lists.php.net to get a copy of this message | ||
<?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)
}
*/
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 2806:107e:13:5b81:fcc2:a7c5:6fa4:7a79)
----
Manual Page -- https://php.net/manual/en/function.array-filter.php
Edit -- https://main.php.net/note/edit/126067
Del: integrated -- https://main.php.net/note/delete/126067/integrated
Del: useless -- https://main.php.net/note/delete/126067/useless
Del: bad code -- https://main.php.net/note/delete/126067/bad+code
Del: spam -- https://main.php.net/note/delete/126067/spam
Del: non-english -- https://main.php.net/note/delete/126067/non-english
Del: in docs -- https://main.php.net/note/delete/126067/in+docs
Del: other reasons-- https://main.php.net/note/delete/126067
Reject -- https://main.php.net/note/reject/126067
Search -- https://main.php.net/manage/user-notes.php