Re: Help with String Manipulation

From: Date: Tue, 27 Apr 2004 06:52:54 +0000
Subject: Re: Help with String Manipulation
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-184731@lists.php.net to get a copy of this message
* and then John W. Holmes declared.... > From: "Nick Wilson" <nick@stylesheet.org> > > > I've never been much good at regex, but it seems there must be a simple > > way to achieve the following: > > > > I have a url that i need to get the 'host' part from for use in email. > > > > This almost works: > > > > <?php > > > > $host=parse_url($base_url); > > $emailaddy="noreply@".$host['host']; > > > > Unfortunately it produces: noreply@www.example.com > > > > So, what's the best way to make sure i got ONLY the host part? > > I assume you mean you only want the "example.com" part, right? > > For examples like this, you just just match everything after the first > period (use strpos() to locate first period, then substr() to pull the > rest). Thanks John, that's perfect. I dont really need to worry too much about the other things you've mentioned (no need for details..) so that'l do nicely ;-) Cheers! -- Nick W

« previous php.general (#184731) next »