I am trying to make a little function to remove stop words from a search query, I will make the array small for the sake of this example:
Function stopWords($input)
{
$stops=array("after","also","an","and");
$noStops=preg_replace("/".$stops."/i","",$input);
$output=str_replace(" "," ",$noStops);
return stripslashes($output);
}
The $noStops preg_replace I need the RegExp that will check for either a space of beginning/end of string. So it doesn't for example take "an" out of "animal" but only if it is a standalone word.
And please, explain WHY it works briefly as I am trying to understand this RegExp thing...I am sure it is very simple, but I learn by example much better than reading theory.
Thanks guys and gals.