Hope you guys can help.
Im trying to build a badwords function, whereby I have my list of bad words in a txt file. I want to run through a keyword array, and check to see if any of the bad words in the text file are inside any of the array contents.
My problem is that the keywords in my array are not single words they can contain multiple words.
Easier to show an example.
If the keyword is "monkey sex" and "sex" is in my list of bad words, I want to unset the word "monkey sex" from my array.
So far I have come up with this below, however it throws out 'Undefined Index' errors.
Any ideas??
function grabandcleankeywords($keyword){
$tempArr=file('data/naughty.txt');
foreach($tempArr as $word){
$word=trim($word);
$nasty[]=$word;
}
$set = mysql_query("select distinct keyword from keywords where keyword like '%$keyword%'");
while ($row = mysql_fetch_row($set)){
$keywords[]=$row[0];
}
$nastyCount = count($nasty);
$keywordCount=count($keywords);
for ($k=0; $k<$keywordCount; $k++){
for ($l=0; $l<$nastyCount; $l++){
if (stristr($keywords[$k], $nasty[$l])){ //throws Undefined index error here
unset($keywords[$k]);
}
}
}
return $keywords;
}