Forum Moderators: coopster

Message Too Old, No Replies

language filter

language filter

         

drooh

2:04 am on Apr 27, 2007 (gmt 0)

10+ Year Member



hey this should be an easy question, i am using a language filter and for some reason I am getting this error

Notice: Undefined variable: stars in C:\Program Files\blahh on line 61

here is my code

function language_filter($string) {
$obscenities = @file("foul_language.txt");
foreach ($obscenities as $curse_word) {
$curse_word = trim ($curse_word);
if (stristr(trim($string),$curse_word)) {
$length = strlen($curse_word);
for ($i = 1; $i <= $length; $i++) {
$stars .="*";
}
$string = eregi_replace($curse_word,$stars,trim($string));
$stars = "";
}
}
return $string;
}

mcavic

2:25 am on Apr 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's trying to add a * to a string that doesn't exist yet. You need to add:
$stars = "";

Just before the "for $i=1" loop.