I got a contact form, I need to filter some words.
I'm doing it as following:
$array = array('lorem', 'ipsum', 'ip.sum');
for($i = 0; $i < count($array); $i++)
{
if( preg_match("/".$array[$i]."/", (string) $field) )
{
return false;
}
}
I'm not a regex master, but it should be working for words like: lorem or ipsum. But it is not.
BTW. Any suggestions how to catch mispelled words, ex. i.psum, l.o.rem?
Update
Of course, I have no empty pattern, I just forgot to paste it.
Update 2
I've decided to got the way suggested by Daniel Vandersluis. Abnyway, I'm not able to make it working.
$field = "ipsum lorem"; // This value comes from textarea
$array = array('ipsum', 'lorem', 'ip.sum');
foreach($array as $term):
if(preg_match('/'.preg_quote($term).'/', $field)) {
return false;
}
endforeach;
Any ideas?