PHP 在提交时在文本区域行末尾添加换行符?
我试图弄清楚如何在使用 php 提交表单时在 textarea 行的末尾添加换行符。目前,我使用 nl2br() 方法在有新行时(当用户按 Enter 时)插入中断标记。但我对如何在每行末尾插入感到困惑。当用户输入的内容超过文本框宽度并跳转到新行时,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|
任何人都可以帮助我吗?
谢谢。
I'm trying to figure out how to add line breaks to the end of a textarea line when submitting a form using php. Currently i have using the nl2br() method to insert a break tag whenever there is a new line (when the user presses enter). But i'm stumped as to how I would insert at the end of every line. The nl2br() method doesn't seem to work when the user enters more then the textbox width and it jumps to a new line.
This small example shows how I want it to insert a break tag..
| = 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|
Can anyone help me with this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现了 wordwrap() 方法。
Found out about the wordwrap() method.