Removing common words from a searched for string PHP

Viewed 3543

OK, so I have a string of words delimited by space i.e.

$commonwords = 'a,an,and,I,it,is,do,does,for,from,go,how,the,etc';

And I receive a search query from $_POST['searchquery'];

I want to remove any common words from the search string, what I am looking for as an end result will be more concise keywords that I can then use to query the database.

So if the user searches for "How do I search for files"

The string becomes "search files" when all common words are removed.

4 Answers
Related