note 114760 deleted from function.array-filter by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 08:10:45 +0000 |
| Subject: | note 114760 deleted from function.array-filter by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212494@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
<?php
function arrayFilter($input, $callback = null) {
foreach($input as $key => &$value) {
if(is_array($value)) {
$value = arrayFilter($value, $callback);
if(is_array($value)) {
if((bool)$value === false) unset($input[$key]);
}
else {
if((bool)($callback ? $callback($value) : $value) === false) unset($input[$key]);
}
}
else {
if((bool)($callback ? $callback($value) : $value) === false) unset($input[$key]);
}
}
return $input;
}
?>