Skip to content

Instantly share code, notes, and snippets.

@praisedpk
Created September 18, 2016 20:22
Show Gist options
  • Save praisedpk/64bdb80d28144aa78d58469324432277 to your computer and use it in GitHub Desktop.
Save praisedpk/64bdb80d28144aa78d58469324432277 to your computer and use it in GitHub Desktop.
Get host or domain name from a URL with PHP
function get_domain_from_url( $string )
{
return strtolower( parse_url( $string , PHP_URL_HOST ) );
}
Source https://pageconfig.com/post/extract-host-from-a-url-php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment