Test PHP function nl2br
The PHP function nl2br
adds a tag <br>
before the breaklines \n
, \r
, \r\n
and \n\r
.
The function
To replace the newlines before calling the
nl2br
does not replace the newlines tags. It only adds a tag <br>
.To replace the newlines before calling the
nl2br
function, you can use this snippets :$out = str_replace("\n", "<br />", $text);