如何在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>更多推荐
发布评论