Last active
December 14, 2015 00:39
-
-
Save jazzsequence/5000545 to your computer and use it in GitHub Desktop.
Gets a specified url, spits it back out as just a domain
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
function get_source( $url ) { | |
$source = parse_url( $url ); | |
$article_source = str_replace( array('www.','www1.','blogs.'), '', $source["host"]); // add whatever prefixes you want here | |
echo $article_source; | |
} | |
// to run this function do this: | |
$url = 'http://www.mydomain.com/some/crazy/path/'; | |
get_source( $url ); // returns mydomain.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment