What I want
I want to get from a URL
the domain
part so from http://example.com/
-> example.com
Examples:
+----------------------------------------------+-----------------------+
| input | output |
+----------------------------------------------+-----------------------+
| http://www..com/questions/ask | www..com |
| http://validator.w3.org/check | validator.w3.org |
| http://www.google.com/?q=hello | www.google.com |
| http://google.de/?q=hello | google.de |
+----------------------------------------------+-----------------------+
I found some related questions in but none of them was exactly what I was looking for.
Thanks for any help!
There's no need to use a regex for this. PHP has an inbuilt function to do just this. Use
parse_url()
: