1.简述
nl to br 意思是 \n编程<br>
nl2br() 函数在字符串中的每个新行(\n)之前插入 HTML 换行符(<br> 或 <br />)。
2.代码
echo nl2br("One line.\nAnother line.",false);
One line.
Another line.
3.补充br2nl
function br2nl($text) {
return preg_replace('/<br\\s*?\/??>/i', '', $text);
}
function br2nl(txt) {
var re = /(<br\/>|<br>|<BR>|<BR\/>)/g;
var s = txt.replace(re, "\n");
return s;
}