php replace \n 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: newline not working php
// When you run a PHP script in a browser, it will be rendered as HTML by default.
// Use <br /> instead or modify the header to content type plain text
echo "Hello <br /> World";