Re: [HAB] str_replace

From: Date: Tue, 22 Feb 2005 16:30:29 +0000
Subject: Re: [HAB] str_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-209182@lists.php.net to get a copy of this message
* OOzy Pal <oozypal@yahoo.com>: > I am trying replace anything between '{!' and '!}' i.e {!A!} and {!B!} > and {!ABC!} with XYZ. I tried the following but no help. Can anyone > help? > > $this->template=str_replace("{!*!}","XYZ",$this->template); str_replace() should be used with static strings; you're going to need a regular expression function. Try: $this->template = preg_replace('/\{!\(.*?)!\}/', '{!XYZ!}', $this->template); -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:matthew@garden.org | http://vermontbotanical.org

« previous php.general (#209182) next »