nl2br php
snippet in php

php replace \n by <br>

user4540

$var = str_replace(array("\r\n","\n"),'<br>', $var);

nl2br php

user1786

because each OS have different ASCII chars for linebreak:
windows = \r\n
unix = \n
mac = \r
  
<?php
echo nl2br("foo isn't\n bar");
?>

nl2br() php

user8049

// add to the functions file
function translateLineBreaks($string) {
	$result = nl2br ($string);
  	return $result;
}