关于案件敏感性的简短问题;Php
这将测试文本区域输入是否存在不好的单词关于案件敏感性的简短问题;Php,php,html,regex,Php,Html,Regex,这将测试文本区域输入是否存在不好的单词 $bad_words = array('bad', 'words') foreach( $bad_words as $bad ){ if( stristr($posted, $bad) !== FALSE ) { $contains_bad_words = TRUE; } } 现在有什么方法可以使这个匹配成为“bad”、“bad”、“bad”、“bad”等,而不必在所有不同的情况下(大字母、小字母)将其写入数组 谢谢我认为应该这样做s
$bad_words = array('bad', 'words')
foreach( $bad_words as $bad ){
if( stristr($posted, $bad) !== FALSE )
{
$contains_bad_words = TRUE;
}
}
现在有什么方法可以使这个匹配成为“bad”、“bad”、“bad”、“bad”等,而不必在所有不同的情况下(大字母、小字母)将其写入数组
谢谢我认为应该这样做
strstrstr
区分大小写,而stristr
不区分大小写。我认为应该这样做strstr
区分大小写,而stristr
不区分大小写
strstr() is case-sensitive. For case-insensitive searches, use stristr().
$bad_words=数组('bad','words');
foreach($bad_words as$bad)if(preg_match(“/$bad/i”,$posted))$包含\u bad_words=TRUE $bad_words=数组('bad','words');
foreach($bad_words as$bad)if(preg_match(“/$bad/i”,$posted))$包含\u bad_words=TRUE