1 options.element.inc _form_options_search($needle, $haystack, $include_pattern)

Recursive function for finding default value keys. Matches on keys or values.

File

core/modules/field/modules/options/options.element.inc, line 374
All logic for options form elements.

Code

function _form_options_search($needle, $haystack, $include_pattern) {
  if (isset($haystack[$needle])) {
    return $needle;
  }
  elseif ($include_pattern && preg_match('/' . $include_pattern . '/', $needle)) {
    return $needle;
  }
  foreach ($haystack as $key => $value) {
    if (is_array($value)) {
      return _form_options_search($needle, $value, $include_pattern);
    }
    elseif ($value == $needle) {
      return $key;
    }
  }
}