any way to get backslashes through in preg_replace?

From: Date: Tue, 08 May 2001 23:06:50 +0000
Subject: any way to get backslashes through in preg_replace?
Groups: php.general 
Request: Send a blank email to php-general+get-51999@lists.php.net to get a copy of this message
Hi folks, In a nutshell, I am doing this: $findIt = array("firstHit","secondHit"); $replaceIt = array("\\341","\\116"); $sourceString = "this is the firstHit and this is the secondHit"; $sourceString = preg_replace($findIt,$replaceIt,$sourceString); the problem is, what I want to result is the following literal text: "this is the \341 and this is the \116" but PHP is evaluating my backslashes as either backreferences, or escaped characters, or something else. How can I pass a replace parameter so that it is literally accepted, and not evaluated in some way? By the way, when I pass: $replaceIt = array("\\\\341","\\\\116"); I get: "this is the \\341 and this is the \\116" I can't afford to run stripSlashes on my resulting string, because it would break other areas of the string. I need to trap this in the preg_replace. ...and yes, I WOULD use str_replace, but it doesn't seem to work in IIS with arrays passed as search & replace parameters. If anyone can verify this, I'd be grateful! Thanks so much, michael Michael Geary Interactive Architect SeraNova (801) 437-5808 michael.geary@seranova.com

« previous php.general (#51999) next »