You are here

function patterns_utils_key_exists in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/utils.inc \patterns_utils_key_exists()

Enhanced version of array_key_exists with support for array of keys

Returns an associative array where to each key is associated the logical value TRUE if it was found in the test array, FALSE otherwise.

Parameters

mixed|Array $key: The key or set of keys to test

Return value

Array $out Associative array of boolean values for each key

See also

array_key_exists

1 call to patterns_utils_key_exists()
taxonomy_patterns_validate in patterns_components/components/taxonomy.inc

File

includes/utils.inc, line 228
Collectiion of general purpose functions.

Code

function patterns_utils_key_exists($key = NULL, $array = array()) {
  $out = array();
  if (!isset($key)) {
    return $out;
  }
  if (!is_array($key)) {
    $key = array(
      $key,
    );
  }
  if (count($key) === 0) {
    return $out;
  }
  foreach ($key as $k) {
    $out[$k] = array_key_exists($k, $array);
  }
  return $out;
}