if ( ! function_exists('getDomainName'))
{
function getDomainName($url)
{
$value = strtolower(trim($url));
$url_patten = '/^(?:(?:[a-z]+):\/\/)?((?:[a-z\d\-]{2,}\.)+[a-z]{2,})(?::\d{1,5})?(?:\/[^\?]*)?(?:\?.+)?$/i';
$domain_patten = '/([a-z\d\-]+(?:\.(?:asia|info|name|mobi|com|net|org|biz|tel|xxx|kr|co|so|me|eu|cc|or|pe|ne|re|tv|jp|tw)){1,2})(?::\d{1,5})?(?:\/[^\?]*)?(?:\?.+)?$/i';
if (preg_match($url_patten, $value))
{
preg_match($domain_patten, $value, $matches);
$host = (!$matches[1]) ? $value : $matches[1];
}
return $host;
}
}
echo getDomainName('gnuwiz.com/index.php');
추천 1 비추천 0
댓글 0