preg_grep搜索非区分大小写

mnl*_*her 1 php case-sensitive preg-match

是否有机会使用非区分大小写的搜索来搜索preg_grep输入?

$checkAuth = preg_grep("/CN=".$cn_name."/", $entries[0]["member"]);
Run Code Online (Sandbox Code Playgroud)

cn_name可以是大写和小写,但它只能使用正确的区分大小写的名称.我知道,preg_match可以和"i"一起使用,如:

preg_match("/php/i", "PHP is the web scripting language of choice.")
Run Code Online (Sandbox Code Playgroud)

但是preg_match需要一个字符串而不使用数组.

pNr*_*Nre 6

做就是了

$checkAuth = preg_grep("/CN=".$cn_name."/i", $entries[0]["member"]);
Run Code Online (Sandbox Code Playgroud)

preg_grep并且preg_match都使用PCRE模式

  • 是的,有:http://php.net/manual/en/function.preg-grep.php,PCRE函数 (2认同)