PHP: Escape Character in XML


function simpleFilter($source){
return str_replace(array(“<“, “>”, “\””, “‘”, “&”), array(“&lt;”, “&gt;”, “&quot;”, “&apos;”, “&amp;”), $source);
}

Advertisements

PHP: Using Ampersand Character From XML String


use htmlspecialchars_decode function

eg: $str = htmlspecialchars_decode($str);

or…

use str_replace function

eg: $str = str_replace(‘&amp;’, ‘&’, $str);

 

source:

http://stackoverflow.com/questions/6379283/remove-amp-from-string-when-writing-to-xml-in-php