domain_alias_best_match($subdomain, $patterns)Given multiple choices for an alias, find the best match.
$subdomain The requested subdomain string.
$patterns An array of patterns and aliase data that match the given subdomain string.
The best match, as an $alias array.
domain_alias/domain_alias.module, line 216
<?php
function domain_alias_best_match($subdomain, $patterns) {
$alias = array();
$test = -1;
$request = explode('.', $subdomain);
foreach ($patterns as $pattern) {
$match = explode('.', $pattern['pattern']);
$count = count(array_intersect($match, $request));
if ($count > $test) {
$test = $count;
$alias = $pattern;
}
}
return $alias;
}
?>