Reputation: 2227
This should not be that hard but I can't seem to find information on it. How do you get line breaks to appear inside a text area when you are echoing it from the server? In other words what is <some code>
in line below?
<text area>first line <some code> second line <some code> third line</text area>
I know how to write out <some code>
. I just need to know what it should be. I have tried \n, \r\n, '\n', "\n", \N
and variations but cannot get the line breaks to display.
Note: This is not about displaying in HTML so <br>
is not what I want. This is not about getting it to display if you are typing it yourself where you can type a carriage return, i.e. :
<textarea>first line
second line </textarea>
When you are outputting from server you cannot use keyboard. This is what code to accomplish above.
Thanks for any suggestions
Upvotes: 0
Views: 1398
Reputation: 131
This is a super old question, but I ran into the same issue ajaxing content into a text area.
Thanks to this answer I used the html code for a new line,
and that worked for me. So basically:
<textarea> Here's my returned text And it gets two lines </textarea>
which (at least for me) comes out as
Here's my returned text
And it gets two lines
Upvotes: 1
Reputation: 422
You need to use "\r\n" (with double quotes) when echoing it out from PHP.
Upvotes: 0
Reputation: 4195
for display \n in html you should use nl2br() php function .
otherwise you should using "\n" (not "/n") for break the line inside your text ;
Upvotes: 0
Reputation: 882
try this
<'p'>firstline<'/p'>
<'p'>secondline<'/p'>
remove comma from p and /p
Upvotes: 0