Hi,
maybe you can try this (extracted from http://www.php.net/manual/en/function.preg-match.php)
<?php
// get host name from URL
preg_match('@^( ?:http://)?([^/]+)@i',
"http://www.php.net/index.html", $matches);
$host = $matches[1];
// get last two segments of host name
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
echo "domain name is: {$matches[0]}\n";...
Leave a comment: