PHP case-insensitive in_array function

前端 未结 11 617
故里飘歌
故里飘歌 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:33

    you can use preg_grep():

    $a= array(
     'one',
     'two',
     'three',
     'four'
    );
    
    print_r( preg_grep( "/ONe/i" , $a ) );
    

提交回复
热议问题