Re: parsing domains

From: Date: Thu, 28 Aug 2003 09:08:55 +0000
Subject: Re: parsing domains
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161017@lists.php.net to get a copy of this message
So why does college suck? Afraid of learning? Anyway, you can solve your problem by simple parsing. An example is below. <?php $TheParse = "www.edmondpaper.com"; $TheNewParse = explode (".", $TheParse); $TheTotal = count($TheNewParse); echo ($TheNewParse[($TheTotal - 2)]); echo ("."); echo ($TheNewParse[($TheTotal - 1)]); ?> This will result in "edmondpaper.com" Obviously there are ways of refining this further, but if college sucks, you might not be interested in learning more :-). At 3:30 AM -0500 on 8/28/03, CollegeSucks.com Mike wrote:
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);
-- =========================== John T. Beresford Apple Certified Technical Coordinator http://www.deewi.com/ 405.760.0794

« previous php.general (#161017) next »