How to save Textarea input after convert line breaks as BR in SQL

淺唱寂寞╮ 提交于 2019-12-01 07:47:49

Just replace the new line \r\n, \r first, then trim it.

$content = preg_replace("/\r\n|\r/", "<br />", $_POST["content"]);
$content = trim($content])

Or:

$content = nl2br($_POST["content"]);
$content = trim($content)

Good luck.

You need to use nl2br for displaying the value, whenever you need it, not for saving it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!