here's my curse word filter:
function filter($string){
global $user;
//for non registered users
if ((!isset($user)) or ($user=="")) {
$querylist=mysql_query("select * from filter where userid='master'");
$list=mysql_result($querylist, 0, 'content');
$listarray=explode(",", $list);
while (list($ArrayIndex, $ArrayContent) = each ($listarray))
{
$string=eregi_replace("$ArrayContent", " *** ", $string);
}
echo $string; }
else {
//for registered users
$querylist=mysql_query("select * from filter where user='$user'");
$list=mysql_result($querylist, 0, 'content');
$listarray=explode(",", $list);
while (list($ArrayIndex, $ArrayContent) = each ($listarray))
{
$string=eregi_replace("$ArrayContent", " *** ", $string);
}
echo $string;
}}
it works fine for the most part, but if a user has their list like so:
$list="CURSE1, CURSE2, CURSE3"
and the string reads
$string="CURSE2, more words CURSE2 CURSE1";
the echo would read:
"CURSE2, more words * *";
it wont filter the first word with any other filters other than the first one on the list
does anybody knows why the first word on the list will not be effected any other word other than the first one on the list?