Answer:
preg_match('@^(?:http://)?([^/]+)@i',"http://blogger.com", $matches);
$host = $matches[1];
// get last two segments of host name
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
echo "domain name is: {$matches[0]}\n";
The output is
domain name is: blogger.com
No comments:
Post a Comment