Skip to content

Instantly share code, notes, and snippets.

@rasec
Created May 27, 2011 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasec/994955 to your computer and use it in GitHub Desktop.
Save rasec/994955 to your computer and use it in GitHub Desktop.
Get the Host of a URL
<?php
function getHost ($url) {
return preg_replace("/^(http[s]?:\/\/|ftp:\/\/)?((www\.)?[a-zA-Z0-9][a-zA-Z0-9-\.]*\.(com|org|net|mil|edu|ca|co.uk|com.au|gov|es))\/(.*)$/", "$2", $url);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment