I'm trying to create a document XML and I have problem with some characters. I need to replace accents and letter ñ.
The output of the following code:
header('Content-type: text/html; charset=utf-8');
var_dump($this->xml_entities_s("Relucí"));
It shows:
string 'Reducí'
When I try to create the XML:
header('Content-type: text/xml; charset=utf-8');
$output = '<?xml version="1.0" encoding="UTF-8"?>';
$output .= $this->xml_entities_s("Relucí");
echo $output;
It shows:
string 'Reducí'
And I want this to show:
string 'Reducí'
I need to show the above because there is a site that get data from my site and they asked for getting data on that way in xml with í
so that it can be parsed correctly.
private function xml_entities_s($string) {
return str_replace(array("<",">",'"',"'","&","á","Á","é","É","í","Í","ó","Ó","ú","Ú","ñ","Ñ"),
array("<",">",""","'","&","á","Á","é","É","í","Í","ó","Ó","ú","Ú","ñ","Ñ"),
$string);
}
Could you help with this? Thanks in advance.