Last active
December 12, 2015 05:49
-
-
Save mindcube/4724974 to your computer and use it in GitHub Desktop.
Function to extract the subdomain off of a url
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
<?php | |
function extract_subdomain () { | |
$url_parts = explode( '.',$_SERVER['HTTP_HOST'] ); | |
unset( $url_parts[0] ); | |
$domain = implode( '.', $url_parts ); | |
return $domain; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment