PHP case-insensitive in_array function

前端 未结 11 605
故里飘歌
故里飘歌 2020-11-29 19:52

Is it possible to do case-insensitive comparison when using the in_array function?

So with a source array like this:

$a= array(
 \'one\'         


        
11条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 20:37

    function in_arrayi($needle, $haystack) {
        return in_array(strtolower($needle), array_map('strtolower', $haystack));
    }
    

    From Documentation

提交回复
热议问题