如何插入“输入”;在数据库中


How to insert "Enter" in database

我有这样的情况:用户在文本区域中插入文本。用户决定什么时候按Enter,所以文本可能是这样的:

text text text text
text text
text
text text 
text
text text text text

该文本进入数据库表,然后在div中回显。问题是,当它被回显时,它看起来像这样:

text text text text text text text text text text text text text

如何在数据库中插入文本,使其在回显时也显示"enter"?

使用php nl2br ()函数

<?php
  echo nl2br("YOUR TEXTAREA VALUE HERE", false);
?>

仅供参考,nl2br类似于:

$details = my string with break lines given by user.
str_replace(array("'r'n", "'r", "'n"), '<br>', $details);
Or 
str_replace(array("'r'n", "'r", "'n"), '<br/>', $details);

它将捕获所有换行,然后添加与nl2br函数相同的