0

I am checking for some spam keywords using PHP preg_match().

The following code doesn't work if dot (.) is included in the $keywords and $str:

<?php
$keywords = array('.co.uk');
$errors = array();
$str = ".co.uk";

foreach($keywords as $keyword)
{
    if(preg_match("/\b($keyword)\b/i", $str))
    {
        $errors[] = "This is spam remove " . $keyword;
    }
}

echo "<pre>";
print_r($errors);
echo "</pre>";
?>

How can I add dot in the pattern /\b($keyword)\b/i?

Sachin
  • 1,646
  • 3
  • 22
  • 59

0 Answers0