Database Searching Word Filter
Posted: Mon Feb 27, 2012 1:47 am
I have developed a database searching script from the tutorial on this site. This is the technique I use to filter out the short words. There is a space at the beginning and end of every word in the array because otherwise it would have filtered out where it matched in the middle of words, so I'd end up with "cody" instead of the word "comedy" in the term array
$wordlist = array(" the ", " at ", " of "," and "." you "," me "," i "); $search = trim(mysql_real_escape_string(strtolower($_POST["search"]))); foreach($wordlist as $word) { $search = str_replace($word, "", $search); } $type = trim(mysql_real_escape_string($_POST["type"])); $term = preg_split("/[,\s]+/", $search);