I have some data in a database that I need represented in an XML file, but the data is different for each request, so the XML file is generated through PHP. For example purposes, let's say this is the text in the db:
Hello & Goodbye
I've tried using the following to get the above (set to the $example
variable) to show up as Hello & Goodbye
in the generated XML:
$example = mb_convert_encoding($example, "utf-8", "HTML-ENTITIES" );
$example = htmlspecialchars_decode($example);
$example = html_entity_decode($example);
$example = str_replace("&", "&", $example);
These lines will replace other entities, like "
, to their proper characters, but not &
. Any idea how to get this working correctly?