public static NestedArray::filter(array $array, callable $callable = NULL)
Filters a nested array recursively.
Parameters
array $array: The filtered nested array.
callable|null $callable: The callable to apply for filtering.
Return value
array The filtered array.
File
- core/lib/Drupal/Component/Utility/NestedArray.php, line 358
Class
- NestedArray
- Provides helpers to perform operations on nested arrays and array keys of variable depth.
Namespace
Drupal\Component\Utility
Code
public static function filter(array $array, callable $callable = NULL) { $array = is_callable($callable) ? array_filter($array, $callable) : array_filter($array); foreach ($array as &$element) { if (is_array($element)) { $element = static::filter($element, $callable); } } return $array; }
Please login to continue.