0

I am trying to save an XML file with a string pulled out of a text file (which is actually a converted PDF to TXT file). In CMD (php.exe) the echo command shows the string normally, without any extra characters, but in an XML file I get a different input.

This is the string that I am trying to save.

Ponedjeljak

In CMD it shows it like this

Ponedjeljak\n

While in XML the string is stored with some extra characters, like this

Ponedjeljak


I have tried using preg_replace like this

preg_replace("/&#\\d+;|\n/", "", $dan);

But the string and the extra line are still saved in the XML. What am I doing wrong here and why is it saving the extra characters in the XML file? Both PHP and XML files are in UTF-8 encoding.

Petar-Krešimir
  • 444
  • 8
  • 22

1 Answers1

1

Try this:

$string = str_replace(array("\n", "\r"), '', $string);
Iberê
  • 1,211
  • 1
  • 11
  • 16