I have a slight problem with inserting newlines in textareas. After I submit the form the text in database shows something like:
“text\r\nfor” (i’m on windows)
For the following text:
“text
for”
Then after I retrieve the respective text from the database in the textarea it shows:
“text\r\n\for”
I’m using PHP and put the text in the textarea like so:
<textarea name="post_content">{$post_content}</textarea>
I want it to render properly with the newline character instead of \n or \r\n .
The text stored in the database has a single
\which means to escape then, which happens before a newline can be rendered.The easiest fix is to store the text with a second
\, like this:This would then be rendered by PHP as:
Which would create the HTML with a newline.