php replace newline with br code example
Example 1: php replace \n by
$var = str_replace(array("\r\n","\n"),'<br>', $var);
Example 2: nl2br() php
// add to the functions file
function translateLineBreaks($string) {
$result = nl2br ($string);
return $result;
}
Example 3: php textarea replace newline with br
$open=str_replace(PHP_EOL,"<br>",$_POST["open"]);