function in_array_case_insensitive($needle, $haystack)
{
return in_array( strtolower($needle), array_map('strtolower', $haystack) );
}
Easy, huh? Here's an example of it in use
$fileExtensionsArray = Array("php", "html", "ASP", "sql", "JSP");
$extension = "PHP";
if (in_array_case_insensitive($extension, $fileExtensionsArray))
{
echo "Yes, $extension is in array";
}
else
{
echo "No $extension is NOT in array";
}
Thanks for this! Didn't realise it was so easy to implement this.
ReplyDeleteThanks for this piece of code.. saved lot of time :)
ReplyDeleteVery clever, helpt me alot, Thanks
ReplyDeleteI am not sure where you are getting your info, but great topic.
ReplyDeleteI needs to spend some time learning more or understanding more.
Thanks for magnificent info I was looking for this information for
my mission.
Here is my page; magento themes
Excellent piece of code. Thank you!
ReplyDeleteWorks great! Thanks
ReplyDeleteWhat if $haystack is array of array.?
ReplyDeleteThis is really Nice Information you shared with us appreciate it
ReplyDelete