Created
June 6, 2012 17:21
-
-
Save sidharthkuruvila/2883400 to your computer and use it in GitHub Desktop.
caselessHasKey
This file contains hidden or 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
| <?php | |
| function caselessHasKey($arr, $str){ | |
| foreach($arr as $k => $v){ | |
| if(strcasecmp($str, $k) === 0) return TRUE; | |
| } | |
| return FALSE; | |
| } | |
| $a = Array("S" => 1, "I" => 2); | |
| echo caselessHasKey($a, "s"); | |
| echo caselessHasKey($a, "d"); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment