Get domain name from a URL

Web-hosting business can now be started for just $19.95 with unlimited resources. Start your own.

Its easy to get domain name or host from a URL using the builtin PHP. function
that can help you extract the domain name or other components of a given URL.

The below code extracts the domain name or host from a URL and then converts it to lower case and returns the string value.
  1. function get_domain_from_url( $string )
  2. {
  3.     return strtolower( parse_url( $string , PHP_URL_HOST ) );
  4. }
PHP Code

As a real world example, try this code:
  1. get_domain_from_url( '!/dSbH2K/' );
PHP Code

  1. High Performance Hosting is now $3.96 a month

© 2012-2017 - Scripts - Twitter