A better pattern for splitting the words of a query up is:
preg_match_all('/[^\w\']/+/', $query, $word)
// $words has the words.
A better pattern for splitting the words of a query up is:
preg_match_all('/[^\w\']/+/', $query, $word)
// $words has the words.