可以说我有不好的话数组:preg_match字符串中的数组项?
$badwords = array("one", "two", "three");
和随机字符串:
$string = "some variable text";
如何创建这个循环:
if (one or more items from the $badwords array is found in $string)
echo "sorry bad word found";
else
echo "string contains no bad words";
例如:
如果$string = "one fine day" or "one fine day two of us did something"
,用户应该看到对不起坏字发现的消息。
如果$string = "fine day"
,用户应该看到字符串包含没有不良词的消息。我知道,你不能preg_match
从数组。任何建议?
$ string是百达一个随机字符串,它的搜索查询更具体的。所以如果访问者输入包含不好的单词的查询,他应该看不到任何结果,否则..那么你明白了吗? :) – DadaB 2012-04-27 22:00:35
和**是的,你可以'preg_match' **一个数组,你只需要先崩溃它。检查我给出的答案。 – 2012-04-28 00:29:12