If you are getting it out out a db, Make a function called profanityFilter($text) { } and then inside it, do a foreach($text as $value) { } and then get from a db like while($row=mysql_fetch_array($query)) { } and inside that do: str_ireplace($row['badword'], $row['replacewith'], $value); Then it will be done.. An example is shown below:
PHP Code:
<?php
// profanity filter
public function profanityFilter($text) {
$query = mysql_query("SELECT * FROM `wordfilter`")or die(mysql_error());
while($row = mysql_fetch_array($query)) {
str_ireplace($row['badword'], $row['replacewith'], $text);
}
}
?>
That may not be exactly right.. but it will get you on the right tracks.
Edit, Another way:
PHP Code:
<?php
function filter($text) {
$badwords = array('one' => '***', 'two' => '***', 'three' => '*****');
str_ireplace($badwords[0], $badwords[1], $text);}
}
?>
Second method doesn't use a db.. It's not as dynamic really..
If this helped you, Please leave rep, Thanks