Re: Re: preg_replace problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux