PHP REGEX: Obtenir de domaine à partir de l'URL

Ce que je veux


Je veux obtenir à partir d'une URL la domain la partie afin de http://example.com/ -> example.com

Exemples:


+----------------------------------------------+-----------------------+
| input                                        | output                |
+----------------------------------------------+-----------------------+
| http://www.stackoverflow.com/questions/ask   | www.stackoverflow.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             |
+----------------------------------------------+-----------------------+

J'ai trouvé que certaines questions liées à stackoverflow mais aucun d'eux n'était exactement ce que je cherchais.

Merci pour toute aide!

InformationsquelleAutor Adam | 2010-08-09