Hello again, I have a basic curse filter working. Trouble is I can only get it to filter one curse word.
The Code that works for filtering one curse word...
<?
$fn = "texts/comments.txt";
$content = nl2br(stripslashes($POST['text'])."\n"."<hr>");
$oldWords = "shit";
$newWords = "st";
$content = str_replace ($oldWords , $newWords , $content);
$fp = fopen($fn,"a") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
echo "<meta http-equiv=\"refresh\" content=\"0; url=comments.php\" />\n";
?>
The Code that doesnt work for filtering multiple curses...
<?
$fn = "texts/comments.txt";
$content = nl2br(stripslashes($POST['text'])."\n"."<hr>");
$oldWords = array( "[shit]","[fuck]");
$newWords = array( "[st]","[f**k]");
$content = str_replace array($oldWords , $newWords , $content);
$fp = fopen($fn,"a") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
echo "<meta http-equiv=\"refresh\" content=\"0; url=comments.php\" />\n";
?>
my PHP knowledge is still very basic but I tried using an array for storing multiple curses. exactly what have i done wrong?