I need a php function which produce a pure domain name from URL. So this function must be remove http://, www and /(slash) parts from URL if these parts exists. Here is example input and outputs:
Input – > http://www.google.com/ | Output -> google.com
Input – > http://google.com/ | Output -> google.com
Input – > http://www.google.com/ | Output -> google.com
Input – > google.com/ | Output -> google.com
Input – > google.com | Output -> google.com
I checked parse_url function, but doesn’t return what I need.
Since, I’m beginner in PHP, it was difficult for me. If you have any idea, please answer.
Thanx in advance.
Works correctly with all your example inputs.