Re: preg_replace problem

From: Date: Fri, 13 Oct 2000 08:09:48 +0000
Subject: Re: preg_replace problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19961@lists.php.net to get a copy of this message
On Fri, 13 Oct 2000, Nicolae Mihalache wrote: > Hello, > I'm trying to write a piece of code which replace in > a string every occurrence of "[something]" with $a["something"] > (a is an array resulted from a mysql_fetch_array). > However for some reason this code does not work: > > <?php > $a["email"]="test@test.com"; > $a["name"]="Foo Bar"; > $string="this is a string containing [email] and [name]"; > > $string=preg_replace("/\[(\w+)\]/e","$a['\\1']",$string); > echo "string=$string"; > All I need to do is to escape "$" from $a. Sorry for disturbing you with dumb questions, Mache

« previous php.general (#19961) next »