Re: Pulling data out of a domain name

From: Date: Wed, 05 Dec 2001 23:45:53 +0000
Subject: Re: Pulling data out of a domain name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76802@lists.php.net to get a copy of this message
In article <9344940740.20011205150008@starband.net>, rdkurth@starband.net wrote: > Is there a more efficient way of doing what this script does is check > a domain name and separate the domain name from the ext. > The domain names could be in a few different formats. Like the > samples below. This script works but I was just wondering does it > have to be so long winded > > www.domain.com www.domain.com.au domain.com domain.com.au > > $number= substr_count ($domaname,"."); <snip verbose code> Regex time (untested, so may need to be tweaked slightly): $domaname=preg_replace("/^(www\.)?(.+)\.com(\.au)$/i","$2",$domaname); -- CC

« previous php.general (#76802) next »