3){ //if the length of word $i is great than 3, continue $word = strtolower($words[$i]); //set $word to lowercase $word = str_replace($f,$r,$word); //replace $f with $r $query2 = mysql_query("select word from searchWords where articleIds=".(int)$article['aid']); //query for word(s) while($word_check = mysql_fetch_array($query2)){ //iterate through all indexed words if(strcmp($word_check['word'],$word)==0){ //if indexed word is equal to the currently selected word $exists = TRUE; //set duplicate exists to TRUE } //end if } //end while if(!$exists){ //check if exists is TRUE mysql_query("INSERT INTO searchWords VALUES (0, '".$word."',".(int)$article['aid'].")") or die(mysql_error()); //insert new word,aid into table } } //end check if exists } //end for loop unset($words); unset($article); } print "Successful!"; print microtime() - $time; } populateKeywords(); ?>