Unable to replace & with & in XML uses Preg_replace in PHP

Posted by Raind on Stack Overflow See other posts from Stack Overflow or by Raind
Published on 2010-06-17T06:50:05Z Indexed on 2010/06/17 6:53 UTC
Read the original article Hit count: 145

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml