and like us on FB

Finding the root domain name (and TLD, or top level domain) from a URL is challenging. Literature on the web generally leans towards a library that’ll find the root domain by way of comparing the URL against all approved top level domains … but this method introduces a degree of complexity that we wanted to avoid. The following function is one that we use to find a domain name root (or TLD). It isn’t perfect, but it’s close.

You may optionally return the top level domain (eg, .com.au or .net) with the argument $tld = true.

Download

Title: Get Root Domain from a URL with PHP
Description: Get Root Domain from a URL with PHP.
Download: PHP Code (V0.3) | Plugin Page

Shortt URL for this post: http://shor.tt/1PvD