ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Building a Simple Search Engine with PHP
Subject:   Giving Back
Date:   2007-01-23 16:52:24
From:   PHPchick
I found this really helpful in getting up & running fast and wanted to give back as a "thanks". So here's a little bit that I added in my version:


/* create an array of words you want to exclude */
$filterWords = array('a', 'about', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'from', 'how', 'i', 'in', 'is', 'it', 'nbsp', 'of', 'on', 'or', 'that', 'the', 'this', 'to', 'was', 'we', 'what', 'when', 'where', 'which', 'with');


... later in the code ...


/* Does the current word already have a record in the word-table? */
$cur_word = addslashes( strtolower($words[$i][$j]) );

/* add the following to filter unwanted words */
if (!in_array( $cur_word, $filterWords)) {
... database selects/inserts...
}


1 to 2 of 2
1 to 2 of 2