Created
July 11, 2013 20:28
-
-
Save EmeraldCoder/5978944 to your computer and use it in GitHub Desktop.
Search a value in a array using a case insensitive check
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
/** | |
* Search a value in a array using a case insensitive check | |
* similar to array_search() but case insensitive | |
* | |
* @param $search | |
* @param array $array | |
*/ | |
private function arraySearchInsensitive($search, array $array) | |
{ | |
foreach ($array as $key => $value) { | |
if (stristr($search, $value)) { | |
return $key; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment