error:preg_match_all(): Compilation failed: nothing to repeat at offset 59
Hello everyone, I am trying to make a word filter for a client and i have ran into the issue that my code witch is pulling words from a text file can not read the $ character from my text file, mycode is below.
$lines=array();
$fp=fopen('/opt/lampp/htdocs/Comments/Classes/Bad.txt', 'r');
while (!feof($fp))
{
$line=fgets($fp);
//process line however you like
$line=trim($line);
//add to array
$lines[] = preg_quote(trim($line));
}
fclose($fp);
$string = Input::get('comments');
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode("|", $lines) . ")\b/i",
$string,
$matches
);
if ($matchFound) {
$this->addError("The following is not allowed please change it.");
$words = array_unique($matches[0]);
foreach($words as $word) {
echo "<li>" . $word . "</li>";
}
echo "</ul>";
}