You are here

public static function ArrayHelper::filterKeys in Helper 7

Filters keys of an array using a callback function.

Parameters

callable $callback: The callback function to use. If no callback is supplied, all keys of array equal to FALSE will be removed.

array $array: The array to iterate over.

Return value

array Returns the filtered array.

1 call to ArrayHelper::filterKeys()
ArrayHelperTest::testFilterKeys in tests/ArrayHelperTest.test

File

lib/ArrayHelper.php, line 89

Class

ArrayHelper

Code

public static function filterKeys(array $array, $callback) {
  return array_intersect_key($array, array_flip(array_filter(array_keys($array), $callback)));
}