Created
November 20, 2014 23:14
-
-
Save ikarius6/35da45ed95507b7256f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Regex generator for valid TLDs - By MrJack*/ | |
$txt = file_get_contents('http://data.iana.org/TLD/tlds-alpha-by-domain.txt'); | |
$tlds = preg_split('/\s+/', $txt); | |
$valid_tld = array(); | |
foreach($tlds as $tld){ | |
if (! preg_match('/[^a-z]+/i', $tld, $matches)){ | |
if(strlen($tld) > 3){ | |
array_push($valid_tld, strtolower($tld)); | |
} | |
} | |
} | |
echo implode("|",$valid_tld)."|[a-z]{2}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment