2013-09-23 112 views
0

是否有機會在preg_grep輸入中搜索不區分大小寫的搜索?preg_grep搜索不區分大小寫

$checkAuth = preg_grep("/CN=".$cn_name."/", $entries[0]["member"]); 

cn_name可以是大寫和小寫形式,但只適用於區分大小寫的正確名稱。我知道,可的preg_match與被用在「我」,如:

preg_match("/php/i", "PHP is the web scripting language of choice.") 

,但需要的preg_match一個字符串,而不是一個陣列工作。

+0

爲什麼你就不能添加'i'標誌'preg_grep'? – elclanrs

+0

可能的重複[我如何使此preg \ _match區分大小寫?](http://stackoverflow.com/questions/12411037/how-do-i-make-this-preg-match-case-insensitive) – MortalViews

+0

可能請閱讀preg_grep – mnlfischer

回答

5

只是不要

$checkAuth = preg_grep("/CN=".$cn_name."/i", $entries[0]["member"]); 

preg_greppreg_match都使用PCRE模式

+0

作品,謝謝!有沒有信息在PHP手冊... – mnlfischer

+2

是的,有:http://php.net/manual/en/function.preg-grep.php,PCRE功能 – pNre