note 112956 deleted from function.array-filter by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 08:13:27 +0000 |
| Subject: | note 112956 deleted from function.array-filter by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212499@lists.php.net to get a copy of this message | ||
Note Submitter: keksnicoh at googlemail dot com
----
Usefull invertation of array_filter
<?php
$data = array(...)
$noArrayData = array_filter_inverse($data, 'is_array');
/**
* Inverts the result of the filter callback.
* @param array $data
* @param callable $f
* @return array
*/
function array_filter_inverse(array $data, callable $f)
{
return array_filter($data, function() use(&$f) {
return ! call_user_func_array($f, func_get_args());
});
}
?>