represents the ASCII "carriage return" character (ASCII code 13
, which is D
in hexadecimal), sometimes written "\r"
, rather than the "linefeed" character, "\n"
(which is ASCII 10
, or A
in hex). Note that when SimpleXML is asked for the string content of a node (with (string)$node
or implicitly with statements like echo $node
) it will turn this "entity" into the actual character it represents.
Depending on your platform (Windows, Linux, MacOS, etc), the standard line-ending, accessible via the built-in constant PHP_EOL
, will be either "\n"
, "\r\n"
, or "\r"
.
The safest way to replace these with HTML linebreak tags (<br>
) is to replace any of these characters, since you don't know which convention the source of the XML data might have been using.
PHP has a built-in function which should be able to do this for you, called nl2br()
. If you want a slightly custom version, there's a comment in the docs from "ngkongs" showing how to use str_replace
to similar effect.