You are here

function select_or_other_multi_array_key_exists in Select (or other) 7.2

Same name and namespace in other branches
  1. 6.2 select_or_other.module \select_or_other_multi_array_key_exists()
  2. 7.3 select_or_other.module \select_or_other_multi_array_key_exists()

Helper function to check keys in multidimensional array.

Parameters

$needle: The key.

$haystack: The array to check.

Return value

Boolean indicating if the key is set.

1 call to select_or_other_multi_array_key_exists()
select_or_other_element_process in ./select_or_other.module
Process callback for a Select (or other) element.

File

./select_or_other.module, line 283
The Select (or other) module.

Code

function select_or_other_multi_array_key_exists($needle, $haystack) {
  if (array_key_exists(html_entity_decode($needle, ENT_QUOTES), $haystack)) {
    return TRUE;
  }
  else {
    foreach ($haystack as $key => $value) {
      if (is_array($value) && select_or_other_multi_array_key_exists($needle, $value)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}