getting base domain and sub domains from url?
| From: | Kenneth Andresen | Date: | Sat, 16 Sep 2006 21:28:15 +0000 |
| Subject: | getting base domain and sub domains from url? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241864@lists.php.net to get a copy of this message | ||
Hello all,
I am trying to extract base domains and sub domains from url's, and
expect there to exist something to do this already.
I used the parse_url($url) to get the host variable.
My thought is to use $domain_elements[]=array_reverse(explode('.',$url));
then simply check $domain_element[0] against some base of
international+country specific extensions, if they have sub-extensions
like "co.uk" then add
a third level to the domain list , and set this up as base domain. Any
levels beyond the registrable domain names would count as sub domains.
What I would like to know is if there are some lists of all these base
domains, or maybe some function already doing what I would like to do?
In advance, thanks!