![](/img/trans.png)
[英]how to insert and display the enter key or new line from codeigniter to database using textarea
[英]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
我该怎么做才能将文本插入数据库,以使它在回显时也显示“ Enters”?
使用php nl2br ()
函数
<?php
echo nl2br("YOUR TEXTAREA VALUE HERE", false);
?>
只是fyi,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函数相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.