search_keywords_variation
- Versions
- 4.6
search_keywords_variation($text)
Loosens up a set of search keywords by adding wildcards, if possible.
Parameters
$text The keywords as entered by the user.
Return value
If more wildcards can be added, the adjusted keywords are returned. If the query is already as loose as possible, NULL is returned.
Code
modules/search.module, line 293
<?php
function search_keywords_variation($text) {
$text = trim($text);
$new = preg_replace('/\*+/', '*', '*'. implode('* *', explode(' ', trim($text))) .'*');
return ($new != $text) ? $new : NULL;
}
?>Login or register to post comments 