I'm censoring words on my site, here is my vode:
function censoring($str3) {
connecttodatabase();
$query= mysql_query("select * from censoring");
list($replacement, $words) = mysql_fetch_row($query;
$words = explode("\n", $words);
foreach ($words as $word) {
$str3 = str_replace("$word","$replacement", $str3);
}
return $str3;
}
The words are stored on seperate lines, configured in a textarea field. It works but not the way I want it to. For example if hat is censored, it only outputs , where I would like it to display **.
Please help.