如何让文本出现在 html 中的差异行上?!当从 mysql 输出时,它们出现在我的文本区域的 diff 行上,也出现在 mysql 内部的 diff 行上。但是在网页中,它全部在一条线上。如何解决?
最佳答案
使用:
string nl2br ( string $string [, bool $is_xhtml = true ] )
它可以处理\n
, \r
, \r\n
或 \n\r
换行符并用 <br />
替换它们
例子:
$yourText = "This is line one.\nThis is line two.";
$yourText = nl2br($yourText);
echo $yourText;
这将导致:
This is line one.<br />This is line two.
关于php - 来自 textarea 和 mysql 的换行符不会出现在 html 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13861877/