Re: Re: preg_replace problem

From: Date: Sun, 14 Jun 2009 12:30:18 +0000
Subject: Re: Re: preg_replace problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-294028@lists.php.net to get a copy of this message
Hi. On Saturday 13 June 2009, Al wrote: > I may not have been very clear. Feed it just "test" with the > quotes. You should get back, "test" the same as you gave it. Instead, > I get back &quote;test&quote; Like Shawn, I have tried your code in isolation and only get the expected results. I looped it over a few test values: <?php $valueList = array('"','"test"','"test&test"','"test&amp;test"'); echo "<pre>\n\n"; foreach ($valueList as $value) { echo "Before: $value\n"; $value=preg_replace("%&(?!amp;)%i", "&amp;", $value); echo "After: $value\n\n"; } echo '</pre>'; ?> outputs (ignoring <pre> as that was just to remove the <br /> for easy reading): Before: " After: " Before: "test" After: "test" Before: "test&test" After: "test&amp;test" Before: "test&amp;test" After: "test&amp;test" The only conclusion is that something else in your code is converting the quotes. Have a look around. HTH Mark

« previous php.general (#294028) next »