You are here

public static function BackgroundImageFormTrait::arrayFilter in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::arrayFilter()
  2. 2.x src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::arrayFilter()

Filters a nested array recursively, from the bottom up.

Parameters

array $array: The filtered nested array.

callable|null $callable: The callable to apply for filtering.

Return value

array The filtered array.

File

src/BackgroundImageFormTrait.php, line 169

Class

BackgroundImageFormTrait
Trait BackgroundImageFormTrait.

Namespace

Drupal\background_image

Code

public static function arrayFilter(array $array, callable $callable = NULL) {
  foreach ($array as &$element) {
    if (is_array($element)) {
      $element = self::arrayFilter($element, $callable);
    }
  }
  return is_callable($callable) ? array_filter($array, $callable) : array_filter($array);
}