/ Published in: PHP
like array_search but compares against a specific key in each element of the array
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function array_search_key($needle, $haystack, $haystackKey, $strict = false) { foreach($haystack as $key => $value) { if($strict) { if($value[$haystackKey] === $needle) return true; } else { if($value[$haystackKey] == $needle) return true; } } } return false; }