Created
December 18, 2013 20:42
-
-
Save ajace/8029523 to your computer and use it in GitHub Desktop.
PHP: array keys search for insensitive input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_keys_i($array, $str){ | |
$results = array(); | |
foreach($array as $key => $value) { | |
if(stristr($str,$value)) { | |
$results[] = $key; | |
} | |
} | |
if(empty($results)) { | |
return false; | |
} else { | |
return $results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment