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

前端 未结 2 1490
甜味超标
甜味超标 2021-01-13 16:12

I use ckeditor in admin panel but in user submit form use simple textbox so user can input text and submit. Problem is when user enter text in textarea with Line Breaks it

2条回答
  •  醉酒成梦
    2021-01-13 16:40

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

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

    Or:

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

    Good luck.

提交回复
热议问题