Get domain name from a URL

Its easy to get domain name or host from a URL using the builtin PHP function parse_url 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.

As a real world example, try this code: