Possible Duplicate:
Get the subdomain from a URL
I have seen posts about using parse_url to get www.domain.tld but how can i just get "domain" using php?
i have got this regex currently
$pattern = '@https?://[a-z]{1,}\.{0,}([a-z]{1,})\.com(\.[a-z]{1,}){0,}@';
but this only works with .com and i need it to work with all TLDs (.co.uk, .com , .tv etc.)
Is there a reliable way to do this, i am not sure if regex is the best way to go or not? or maybe explode on "." but then again subdomains would mess it up.
EDIT
so the desired outcome would be
$url = "https://stackoverflow.com/questions/11952907/get-domain-without-tld-using-php#comment15926320_11952907";
$output = "stackoverflow";
Doing more research would anyone advise using parse_url to get www.domain.tld then using explode to get domain?