extract domain name from a URL

From: Date: Wed, 02 Oct 2002 19:18:11 +0000
Subject: extract domain name from a URL
Groups: php.general 
Request: Send a blank email to php-general+get-118636@lists.php.net to get a copy of this message
Folks, I want to keep track of referers to my site. I want to store the domain name of the referer in a db field. I want 'just' the domain name, not the full url. So I need a snippet of code that could parse the $HTTP_REFERER, and return just the domain name. Example.... 1) http://www.google.com 2) http://www.google.com/ 3) http://www.google.com/search?sourceid=navclient&q=evil+microsoft ... would all give me http://www.google.com Could anyone give me a hand? Thanks! -- : Joseph Szobody : "Computers are like airconditioners: They stop working properly if you open windows."

« previous php.general (#118636) next »