function _form_options_search in Options Element 7
Same name and namespace in other branches
- 6 options_element.inc \_form_options_search()
Recursive function for finding default value keys. Matches on keys or values.
1 call to _form_options_search()
- _form_type_options_value in ./
options_element.inc - Logic function for form_type_options_value(). Do not call directly.
File
- ./
options_element.inc, line 442 - All logic for options_element 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;
}
}
}