Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Bad words filter

Bad word filter with php and mysql



9:11 pm on May 15, 2004 (gmt 0)

How can i go about getting a bad words filter that uses mysql for ease of editing , deleting , and adding filter words
--Thanks in advance


1:44 am on May 16, 2004 (gmt 0)

10+ Year Member

function edit_words($STRING,$bannedwords) {
foreach($bannedwords as $key => $v) {
$STRING = eregi_replace($v,"*@!\$",$STRING);
return $STRING;

//i don't know how to populate the list using mySQL, never used it
$words = array('this','that','and','the','other','thing');

// call it like this
$uneditedString = "hi, this and that and the other thing. yup!";
$edited = edit_words($uneditedString,$words);

hope this helps a little, i'm sure there are much better ways


4:22 pm on May 19, 2004 (gmt 0)

10+ Year Member

MYSQL_QUERY (SELECT * FROM bad words list.....



for($x=0; $x< count($badWords); $x++)
$input = eregi_replace($badWords[$x], "****", $input);


Replaces bad words with **** in $input


Featured Threads

Hot Threads This Week

Hot Threads This Month