php - Displaying a Paragraph with line breaks
I have a situation where users can enter a question and this is written into a mysql table.
I then show this text in an admin panel for reivew and reply.
I can see the text in the admin panel has the same new lines (chrome developer) but it shows as one block of text (no new lines)...
I'm currently using to show this text... I've tried a but it still hows without line breaks.
How should I go about displaying this text with the new lines it contains? Is there a HTML tag to do this or do I need to use PHP and sub \n for br tag?
example below:
<span class="description">txthere
txthere
txthere
txthere
txthere.</span>
Answer
Solution:
On display you can use CSS to style the HTML with the original line breaks, try
white-space
:Answer
Solution:
if it is textarea or console basically it puts a line break using
/n
which is not recognized by the browser as line break, you need to convert/n
to<br/>
to tell the browser that this is a line break, use this php's functionmore information here: http://in.php.net/nl2br
this will convert all your
/n
tag to<br/>
tag so that browser process it as line breaks