Unable to replace & with & in XML uses Preg_replace in PHP
- by Raind
Hi,
Need help here. Am not able to replace the '&' with '&' uses Preg_replace in PhP. But, if i do it manually (edited) on the xml file, it works out fine.
Here are the sample:
$XMLCharactersPreg = "/[&<\"\'()^*@+]/";
$XMLPregReplace = "&";
$d_Description = "50% offer & 20% further reduction for member";
if (preg_match($XMLCharactersPreg, $d_Description)) {
echo "A match was found.";
$XMLDealDescription = preg_replace($XMLCharactersPreg , $XMLPregReplace, $d_Description);
echo "$XMLDealDescription ";
} else {
echo "A match was not found.";
}
Thanks.