You are here

protected function BulkEditFormTrait::filterOnKey in Views Bulk Edit 8.2

Provides same functionality as ARRAY_FILTER_USE_KEY for PHP 5.5.

Parameters

array $array: The array of data to filter.

callable $callback: The function we're going to use to determine the filtering.

Return value

array The filtered data.

File

src/Form/BulkEditFormTrait.php, line 362

Class

BulkEditFormTrait
Common methods for Views Bulk Edit forms.

Namespace

Drupal\views_bulk_edit\Form

Code

protected function filterOnKey(array $array, callable $callback) {
  $filtered_values = [];
  foreach ($array as $key => $value) {
    if ($callback($key)) {
      $filtered_values[$key] = $value;
    }
  }
  return $filtered_values;
}