Backport new utility function for compatibility reasons

pull/280/head
Thomas Bruederli 9 years ago
parent 2c0861495b
commit 4ba89c9f99

@ -984,6 +984,28 @@ class rcube_utils
return $as_array ? $arr : join(" ", $arr);
}
/**
* Compare two strings for matching words (order not relevant)
*
* @param string Haystack
* @param string Needle
* @return boolen True if match, False otherwise
*/
public static function words_match($haystack, $needle)
{
$a_needle = self::tokenize_string($needle, 1);
$haystack = join(" ", self::tokenize_string($haystack, 1));
$hits = 0;
foreach ($a_needle as $w) {
if (stripos($haystack, $w) !== false) {
$hits++;
}
}
return $hits >= count($a_needle);
}
/**
* Parse commandline arguments into a hash array
*

Loading…
Cancel
Save