I have tried a lot but nothing is working. I want to import a XML-file with PHP. In some strings the customer puts some ANSI-Code Carrier Returns (" "). I have tried to remove them with:
str_replace('\r', '', $xml->description);
I also tried it with "&\#13;"
, "\r\n"
, "\&\\#13\;"
in the search but nothing works. Do you have any idea how to remove these linebreaks?
Thanks!
Since your XML processor is already handling de-entitying the entities, you'll be left over with plain ASCII \n or \r or \r\n. PHP does not handle \r or \n inside of single quotes. It only translates them to their respective characters (codes 10 and 13), when the \r and \n are inside of double quotes.
You just need to use "\n" or maybe "\r\n".
Should just be a simple case of:
str_replace(' ', '', $xml->description);
Notice I haven't escaped the #
with a \
.
Actually, This runs just fine
$str = "&\#13;"; //just an example
echo str_replace("&\\#13;", "hello", $str);
Demo
This worked for me:
str_replace("\x13", '', $str);
I'm using the hexcode for that char.