Good Morning,
I'm currently trying to replace some strings from an xml document, some of them are working well but some others aren't and I can't figure out why... can this problem come from the fact the xml was written using Microsoft Word ?
Here is my PhP code:
<?php
$document = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../wwwPublic/vehicule_ci/assets/res/annulation.xml");
$document = str_replace('@ville@', "test_ville", $document);
$document = str_replace('@date@', date('d/m/Y'), $document);
$document = str_replace('@emetteur@', "test_emetteur", $document);
$handle = fopen(utf8_decode($documentPath), "w");
fwrite($handle, $document);
fclose($handle);
echo $document;
?>
Here is the output:
test_ville le 20/04/2017Ref Client : @emetteur@N° Voucher :ÉmetteurDestinataireNom :@emetteur@
as you can see, the "ville" and the "date" are being replaced correctly, but the "emetteur" isn't..., If someone got an idea, I'll take it.
Thank you
It is most likely due to the fact that the document was written in word. I've experienced errors like this before too. Maybe you need to convert the document using the iconv function.