【问题标题】:PHP adding Line breaks to the end of a textarea line on submit?PHP在提交时将换行符添加到textarea行的末尾?
【发布时间】:2011-10-30 07:51:59
【问题描述】:

我试图弄清楚在使用 php 提交表单时如何在 textarea 行的末尾添加换行符。目前我已经使用 nl2br() 方法在有新行时插入中断标记(当用户按下回车键时)。但我对如何在每行末尾插入感到困惑。当用户输入的内容超过文本框宽度并跳转到新行时,nl2br() 方法似乎不起作用。

这个小例子展示了我希望它如何插入一个中断标签..

| = end of text area line

Text Text Text Text Text Text Text Text| <---- Insert break tag here.
Text Text Text Text Text Text Text Text|
Text Text Text Text Text Text Text Text|
Text Text Text Text Text Text Text Text|
Text Text Text Text Text Text Text Text|

谁能帮我解决这个问题?

谢谢。

【问题讨论】:

  • 您所要求的通常称为“自动换行”。
  • 谢谢,我发现 wordwrap() 方法似乎有效。

标签: php break


【解决方案1】:

了解 wordwrap() 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-21
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 2015-11-01
    • 2013-12-09
    • 2020-08-14
    相关资源
    最近更新 更多