<?php
function getdomainname($url)
{
$pieces = parse_url($url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
return $regs['domain'];
}
return false;
}
print getdomainname("http://gauravraimca.blogspot.com/feeds/posts/default?alt=rss"); // outputs 'blogspot.com'
?>
function getdomainname($url)
{
$pieces = parse_url($url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
return $regs['domain'];
}
return false;
}
print getdomainname("http://gauravraimca.blogspot.com/feeds/posts/default?alt=rss"); // outputs 'blogspot.com'
?>
No comments:
Post a Comment