Is it possible to do case-insensitive comparison when using the in_array function?
So with a source array like this:
$a= array(
\'one\'
I wrote a simple function to check for a insensitive value in an array the code is below.
function:
function in_array_insensitive($needle, $haystack) {
$needle = strtolower($needle);
foreach($haystack as $k => $v) {
$haystack[$k] = strtolower($v);
}
return in_array($needle, $haystack);
}
how to use:
$array = array('one', 'two', 'three', 'four');
var_dump(in_array_insensitive('fOUr', $array));