Revision: 28902
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 16, 2010 01:00 by iloveitaly
Initial Code
function array_search_key($needle, $haystack, $haystackKey, $strict = false) {
foreach($haystack as $key => $value) {
if(isset($value[$haystackKey])) {
if($strict) {
if($value[$haystackKey] === $needle) return true;
} else {
if($value[$haystackKey] == $needle) return true;
}
}
}
return false;
}
Initial URL
Initial Description
like array_search but compares against a specific key in each element of the array
Initial Title
Array Search on Key
Initial Tags
search, array
Initial Language
PHP