".expand_to_sphinx_query($input)."\n\n"; $input = "one two three four"; print "$input => ".expand_to_sphinx_query($input)."\n\n"; $input = "one two"; print "$input => ".expand_to_sphinx_query($input)."\n\n"; $input = "one"; print "$input => ".expand_to_sphinx_query($input)."\n\n"; function expand_to_sphinx_query($input) { $words = explode(" ",$input); if (count($words) < 2) { return $input; } $bits = array(); for($q=0;$q 2) $bits[] = "\"$input\""; $bits[] = "($input)"; return implode(' | ',$bits); }