if you just need the top level domain (eg .nz) the substr or explode way is the easiest. if you want to separate the domain part from the tld part (eg match .co.nz instead .nz) you need a matching table or you know the amount of domains/subdomains in front of your TLD. there is no easy other way to accomplish it. lenz
On Tue, Jan 27, 2009 at 9:59 AM, speed3r <[email protected]> wrote: > > Amen to that. Of course substr($hoststr, strrpos('.', $hoststr)+1) > will get you the characters immediately following the last . character > in the string. Now show me how you prove it's a top-level domain! > (Especially now the naming schema has been relaxed). > > > On Jan 27, 9:06 am, Matias Gertel <[email protected]> wrote: > > Be really carefull when using code wich assumes certain conditions! > > Why this regular expersion will fail half of the time: > > - It assumes the url starts with www. Wrong! eg: mail.google.com > > - It assumes the url has 4 parts. Wrong! eg:www.google.com > > - It assumes the 3rd part has 2 characters. Wrong: eg:www.google.com.au > > - It assumes the 4th part has 2 characters. Wrong! eg: > www.maps.google.com > > > > Any of the other examples provided in this thread will work as a > > charm, but the errors above are common in people who concentrate on > > solving one example instead of thinking about the big picture. > > > > -- iWantMyName.com painless domain registration (finally) --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected] -~----------~----~----~----~------~----~------~--~---
