public function SearchApiAutocompleteSearch::splitKeys in Search API Autocomplete 7
Split a string with search keywords into two parts.
The first part consists of all words the user has typed completely, the second one contains the beginning of the last, possibly incomplete word.
Return value
array An array with $keys split into exactly two parts, both of which may be empty.
File
- ./
search_api_autocomplete.entity.php, line 252 - Contains SearchApiAutocompleteSearch.
Class
- SearchApiAutocompleteSearch
- Describes the autocomplete settings for a certain search.
Code
public function splitKeys($keys) {
$keys = ltrim($keys);
// If there is whitespace or a quote on the right, all words have been
// completed.
if (rtrim($keys, " \"") != $keys) {
return array(
rtrim($keys, ' '),
'',
);
}
if (preg_match('/^(.*?)\\s*"?([\\S]*)$/', $keys, $m)) {
return array(
$m[1],
$m[2],
);
}
return array(
'',
$keys,
);
}