I need to know how to get the domain name from a url without the tld.
This is what I have that works for .com, .info, etc but not for .co.uk
// get host name from URL
preg_match('@^(?:http://)?([^/]+)@i',
"http://example.co.uk", $matches);
$host = $matches[1];
// get last two segments of host name
preg_match('/([^.]+)\.[^.]+$/', $host, $matches);
echo "domain name is: {$matches[1]}\n";
When I get it to call "example.co.uk" domain it just shows: "co" when I need it to show "example"
Thanks