如何在textarea中替换\ r \ n(How to replace \r\n in textarea)

编程入门 行业动态 更新时间:2024-10-26 19:27:50
如何在textarea中替换\ r \ n(How to replace \r\n in textarea)

PHP代码

<?php $content = "check1\r\ncheck2\r\ncheck3\r\nend..." $order = array("\r\n"); $replace = "\n"; $content= str_replace( $order, $replace, $content); $smarty->assign('content', $content); ?>

查看页面(一个聪明的模板)

<textarea>{$content}<textarea>

输出:

check1\r\ncheck2\r\ncheck3\r\nend...

我期望输出如下

check1 check2 check3 end...

在textarea里面。 我已将\r\n替换为\n ,但即使如此,我仍无法获得所需的输出。 我的代码有什么问题? 先谢谢你。

PHP Code

<?php $content = "check1\r\ncheck2\r\ncheck3\r\nend..." $order = array("\r\n"); $replace = "\n"; $content= str_replace( $order, $replace, $content); $smarty->assign('content', $content); ?>

View page (a smarty template)

<textarea>{$content}<textarea>

Output:

check1\r\ncheck2\r\ncheck3\r\nend...

I expect output like below

check1 check2 check3 end...

inside the textarea. I had replaced \r\n into \n, but even then I can't get my desired output. Whats wrong in my code? Thank you in advance.

最满意答案

看起来你有类似的问题。

如果我正确阅读,请尝试:

<textarea>{$content|stripcslashes}<textarea>

It looks like you're having a similar problem to this.

If I'm reading correctly, try:

<textarea>{$content|stripcslashes}<textarea>

更多推荐

本文发布于:2023-07-17 07:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   textarea   replace

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!