PHP case-insensitive in_array function

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

    $user_agent = 'yandeX';
    $bots = ['Google','Yahoo','Yandex'];        
            
    foreach($bots as $b){
         if( stripos( $user_agent, $b ) !== false ) return $b;
    }
    

提交回复
热议问题