I have a string stored in a database like hello, \r\n how are you? \r\n
. I want to print this string in textarea to edit the text. Which is the appropriate method to print new line in textarea instead of \r\n
? I have tried nl2br(str_replace('\r\n', '\n', $str));
but it will print \n
as it is. I got my result by using
<?php echo str_replace ('\\', '' ,str_replace('<br />', PHP_EOL, str_replace('\r\n', '<br />', $str))); } ?>
Another solution I got from here is
str_replace('\r\n', ' ', $str);
But can anyone tell me what is
. It seems HTML Entity Number
. But I don't know what is it actually.
Is there any better way to do this?
?](https://stackoverflow.com/questions/5946114/how-to-replace-r-n-with-br) – Cemal Feb 22 '18 at 09:53
', $str));` maybe? Assuming you have quite literally got the character sequence `\r\n` in the database... – CD001 Feb 22 '18 at 09:58
how are you?
` . – softech Feb 22 '18 at 10:35
` tags before each new line. – CD001 Feb 22 '18 at 11:03