Re: parsing domains

From: Date: Thu, 28 Aug 2003 09:05:25 +0000
Subject: Re: parsing domains
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161015@lists.php.net to get a copy of this message
Collegesucks.Com Mike wrote:
Quick question... I parse domains in my scripts like this to get the .domain.com out of www.domain.com. However, if someone visits my site with just domain.com in the url, I get .com back as the parsed domain. How can I make it so I aways get the .domain.com no matter what they use? Here is an example of what I use now... $parseddomain = preg_replace('/.+?(\..+)/', '$1', $domain);
this should do it: $parseddomain=preg_replace('/.*?([^.]*\.[^.]*)/','\\1',$domain); Kae

« previous php.general (#161015) next »