php getting domain name from subdomain

php getting domain name from subdomain  using -'php,dns,subdomain'

I need to write a function to parse variables which contain domain names. It's best I explain this with an example, the variable could contain any of these things:

But when passed through my function all of these must return either or, the root domain name basically. I'm sure I've done this before but I've been searching Google for about 20 minutes and can't find anything. Any help would be appreciated.

EDIT: Ignore the, presume that all domains going through this function have a 3 letter TLD.

asked Sep 30, 2015 by vickeykumar66
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.