nl2br()
uses whatever line endings were present in its input. If you don't want to see \r\n
in the output, convert it to \n
before you pass it in.
This isn't explicitly stated in the documentation for this function, but it's implied heavily by the description, which reads (emphasis mine):
Returns string with
'<br />'
or'<br>'
inserted before all newlines (\r\n
,\n\r
,\n
and\r
).
And it's borne out by testing.