How to get the domain name from an url with PHP?
Posted
by
ilhan
on Stack Overflow
See other posts from Stack Overflow
or by ilhan
Published on 2011-11-25T00:29:34Z
Indexed on
2011/11/25
1:50 UTC
Read the original article
Hit count: 217
php
For example
http://www.google.com/ -> google.com
http://www.ma219.metu.edu.tr -> metu.edu.tr
https://www.nic.tr/ -> nic.tr
http://www.plasticsurgery.a.bg/ -> plasticsurgery.a.bg
www.abv.bg -> abv.bg
abv.bg -> abv.bg
The output should not have subdomain.
Edit: It would be great if we were able to read http://mxr.mozilla.org/mozilla/source/netwerk/dns/src/effective_tld_names.dat?raw=1
© Stack Overflow or respective owner