i have a simple forum script set up for an rpg game, and i would like to create a profanity filter for it. i would like to be able to store the swear words and the text to replace each word in a database so that words can be easily added or deleted from the database by a web interface.
here's what i ahve so far. im not even sure if what im trying to do is possible, which would explain why i havent been able to get it to work :p
$swear = "array(";
$censor = "array(";
$swearquery = doquery("SELECT * FROM {{table}}", "swear");
while ($swearrow = mysql_fetch_array($swearquery)) {
$swear .= "\"".$swearrow["swear"]."\", ";
$censor .= "\"".$swearrow["censor"]."\", ";
}
$swear .= ")";
$censor .= ")";
$content = str_ireplace($swear, $censor, $content);
what im trying to do is build an array from the database for str_ireplace to use. $swear and $censor come out as array("blah", "blahrg", "bkahd", ) with appropriate words pulled from the database, but swear words arent replaced. is this method even possible? is there a better way?
any help is greatly appreciated!