Try something like the following. $text contains the text you wish to take the bad words out of:
<?php
$find = array(
'badword1',
'badword2',
'badword3',
'badword4'
);
$replace = array(
'********',
'********',
'********',
'********'
);
function stri_replace($find,$replace,$string)
{
if(!is_array($find)) $find = array($find);
if(!is_array($replace)) $replace = array($replace);
foreach($find as $fKey => $fItem)
{
$between = explode(strtolower($fItem),strtolower($string));
$pos = 0;
foreach($between as $bKey => $bItem)
{
$between[$bKey] = substr($string,$pos,strlen($bItem));
$pos += strlen($bItem) + strlen($fItem);
}
$string = implode($replace[$fKey],$between);
}
return($string);
}
echo stri_replace($find,$replace,$text);
?>