Click to See Complete Forum and Search --> : Censoring a $message?


holynunkenobi
02-09-2004, 05:18 PM
I got the coding that allows the other.txt file to be opened and words submitted to it as you can see below

<?php

$file_loc = "other.txt";

$new_file = fopen($file_loc, "a");
fwrite($new_file, "$message ");
fclose($new_file);
?>

How to I change it so that if bad words (ie swearing) are put into $message they get replaced?

Sam
02-09-2004, 05:46 PM
$filter="word1|word2|word3";
$filterArray=explore($filter,"|");
for($i=0;$i<count($filterArray);$i++)
{
preg_replace("/$filterArray[$i]/","*Explitive*,$message);
}