Skip to content

Instantly share code, notes, and snippets.

@sidharthkuruvila
Created June 6, 2012 17:21
Show Gist options
  • Select an option

  • Save sidharthkuruvila/2883400 to your computer and use it in GitHub Desktop.

Select an option

Save sidharthkuruvila/2883400 to your computer and use it in GitHub Desktop.
caselessHasKey
<?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