Re: [PHP] Re: preg_replace problem
[email protected] (Mark Kelly)
| Newsgroups | php.general |
|---|---|
| Organization | Obscure Technical Services |
| Message-ID | <[email protected]> |
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 "e;test"e;
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&test"');
echo "<pre>\n\n";
foreach ($valueList as $value) {
echo "Before: $value\n";
$value=preg_replace("%&(?!amp;)%i", "&", $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&test"
Before: "test&test"
After: "test&test"
The only conclusion is that something else in your code is converting the
quotes. Have a look around.
HTH
Mark