[thelist] PHP: getting domain names from a url - being foiled by .co.uk addresses

Ken Moore psm2713 at hotmail.com
Sat Dec 6 14:21:46 CST 2003

Hi Dunston,

Dunstan Orchard wrote

>Hi there,
>This is a tricky one I think.
>I have a collection of URLs, for example:
>I need to get only the main domain names from this list, eg:

Not so tricky at all. Assuming that there are a set number of top-level 
domains (com, gov, net) and that there is a set number of characters (".", I 
think is the only one) that begin the TL name, do a string processing 
routine that looks for the "." and the TL domain such as "com". Take those 
four characters and all of the ones back to the ".".

That should do it.

Ken - Who wouldnot string you along.

Cell phone ‘switch’ rules are taking effect — find out more here. 

More information about the thelist mailing list