Skip to content

Instantly share code, notes, and snippets.

@mindcube
Last active December 12, 2015 05:49
Show Gist options
  • Save mindcube/4724974 to your computer and use it in GitHub Desktop.
Save mindcube/4724974 to your computer and use it in GitHub Desktop.
Function to extract the subdomain off of a url
<?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