How to replace \ r \ n in textarea

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);
?>

Browse page (smarty template)

<textarea>{$content}<textarea>

Conclusion:

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

I expect an exit as shown below

check1
check2
check3
end...

inside the text box. I replaced \r\nwith \n, but even then I can not get the desired result. What is wrong in my code? Thank you in advance.

+3
source share
4 answers

It looks like you are having a similar problem with this .

If I read correctly try:

<textarea>{$content|stripcslashes}<textarea>
+6
source

I am not a smart guru, but you may want this in your template:

<textarea>{$content|stripslashes}<textarea>
+3
source

\r\n \n.

$content = str_replace("\r\n", "\n", $content);

, .

+1

\r\n, (.. \r\n \\r\\n), :

$content = str_replace("\\r\\n","\r\n",$content);

0

All Articles