Created
August 21, 2015 08:40
-
-
Save maxkostinevich/0e4c662b9beb10a89d74 to your computer and use it in GitHub Desktop.
Get Website Domain TLD
This file contains hidden or 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
// Get Website Domain TLD | |
function get_site_tld($url){ | |
$host = parse_url($url); | |
preg_match('/(.*?)((\.co)?.[a-z]{2,4})$/i', $host['host'], $m); | |
$ext = isset($m[2]) ? $m[2]: ''; | |
return $ext; // Domain TLD | |
} | |
// For WP just call | |
get_site_tld( get_site_url() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment