Re: preg_replace() in 4.0.4

From: Date: Mon, 08 Jan 2001 00:22:08 +0000
Subject: Re: preg_replace() in 4.0.4
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33146@lists.php.net to get a copy of this message
escape the $ signs in the replace array first, so $1 becomes \$1, etc. Daniel Baldoni wrote: > G'day folks, > > With the upgrade to 4.0.4, preg_replace() now does substitutions for $n in > the replacement strings (I say strings, because it's the easiest way of doing > mass substitutions over an array). This has caused me severe grief (as there > doesn't appear to be any way to stop it). > > I have an application which reads in a PostScript template file and replaces > occurrences of '@' delimited strings with specific values (basically, a > "variable subsituter"). Some of the replacement strings may contain dollar > amounts and so a '$' may (or may not) be present. If a '$' is present in a > string, it will be followed by a digit. When I call preg_replace() in this > application, all 3 arguments are arrays. > > What I'm looking for is some alternative method to do what I'm doing without > writing a custom array_walk()er. If str_replace() or ereg_replace() could > work on arrays as preg_replace() does, that'd be fine. Alternatively, if > there was some way to tell preg_replace() to *NOT* do the substitution, > that would work (for me) to. > > Any suggestions? Thanks in advance. > > -- > -------------------------------------------------------+--------------------- > Daniel Baldoni BAppSc, PGradDipCompSci | Technical Director > require 'std/disclaimer.pl' | LcdS Pty. Ltd. > -------------------------------------------------------+ 856B Canning Hwy > Phone/FAX: +61-8-9364-8171 | Applecross > Mobile: 041-888-9794 | WA 6153 > URL: http://www.lcds.com.au/ | > Australia > -------------------------------------------------------+--------------------- > "Any time there's something so ridiculous that no rational systems programmer > would even consider trying it, they send for me."; paraphrased from "King Of > The Murgos" by David Eddings. (I'm not good, just crazy) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#33146) next »