You need some method for storing the words that you are going to filter for. You can do this with either a text file of with your database. It makes no odds which method you choose, though personally I tend to opt for db.
Then you need to loop through your list of words replacing them if they exist in the content.
$sql = "SELECT words FROM tbl_filter";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
$word = $row['words'];
$replace = 'naughty word';
str_replace ( $word, $replace, $content);
}
You could do this by passing all of the words from the db into the "str_replace()" function as an array.
This is just a simple example, but you should be able to get the idea.
There are a few examples on HotScripts.com that might give you more ideas.
Hope this helps 😉