Organizational Research By

Surprising Reserch Topic

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:

here.example.com
example.com
example.org
here.example.org


But when passed through my function all of these must return either example.com or example.co.uk, 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 .co.uk, presume that all domains going through this function have a 3 letter TLD.
    

asked Sep 30, 2015 by pradip.bhoge
0 votes
226 views



Related Hot Questions

16 Answers

0 votes
NULL
answered Sep 30, 2015 by rolvyrf
0 votes
NULL
answered Sep 30, 2015 by deven.bendale
0 votes
NULL
answered Sep 30, 2015 by 20shahi
0 votes
NULL
answered Sep 30, 2015 by girisha
0 votes
NULL
answered Sep 30, 2015 by ankitarajoria4
0 votes
NULL
answered Sep 30, 2015 by ankitarajoria4
0 votes
NULL
answered Sep 30, 2015 by rajeshujade
0 votes
NULL
answered Sep 30, 2015 by android_master
0 votes
NULL
answered Sep 30, 2015 by vibhorsingh
0 votes
NULL
answered Sep 30, 2015 by yogeshplv
0 votes
NULL
answered Sep 30, 2015 by 20shahi
0 votes
NULL
answered Sep 30, 2015 by shegokar.anjeet
0 votes
NULL
answered Sep 30, 2015 by suyesh.lokhande
0 votes
NULL
answered Sep 30, 2015 by jekbishnoi
0 votes
NULL
answered Sep 30, 2015 by vijayshukla80
0 votes
NULL
answered Sep 30, 2015 by yashwantpinge

...