Converts new line characters to html tags.
New line characters have no effect in a web browser. To get a line break, the <br> tag should be used. nl2br() converts all new line characters in a string to <br> tags.
<?php
$s = "This is \na text with \nline breaks";
print "$s<br><br>";
print nl2br($s);
?>
This is a text with line breaks
This is
a text with
line breaks
This code shows how nl2br can be used to give new line characters effect in a web browser.