Here is a design though: For example is I put a link such as
http://example.com
in textarea. How do I get PHP t
If you want to trust the IANA you can get your current list of offcially supported TLDs in use there like:
$validTLDs =
explode("\n", file_get_contents('http://data.iana.org/TLD/tlds-alpha-by-domain.txt')); //get the official list of valid tlds
array_shift($validTLDs); //throw away first line containing meta data
array_pop($validTLDs); //throw away last element which is empty
Makes Søren Løvborg's solution #2 a bit less verbose and spares you the hassle of updating the list, nowadays new tlds are thrown out so carelessly ;)