PHP 在提交时在文本区域行末尾添加换行符?

发布于 2024-12-13 06:39:48 字数 501 浏览 3 评论 0原文

我试图弄清楚如何在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神仙妹妹 2024-12-20 06:39:48

发现了 wordwrap() 方法。

Found out about the wordwrap() method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文