0

Hi guys when I save with php some part of text (with break of lines) for example:

this is 

an example

in my database I see like I wrote it

enter image description here

But when I echo this data from my database I see it wrong

enter image description here

Can you help me?

My code is this

echo '<p class="date">' . $date . "</p>";
echo '<p class="post">' . $posts . "</p>";
Davide Rossi
  • 73
  • 11

2 Answers2

3

you can check nl2br function (http://php.net/nl2br)

echo '<p class="date">' . $date . "</p>";
echo '<p class="post">' . nl2br($posts) . "</p>";
engvrdr
  • 541
  • 2
  • 9
0

The problem is that HTML doesn't break line with newline character. PHP provides a function that converts newlines to <BR> tags. http://www.w3schools.com/php/func_string_nl2br.asp

Enhex
  • 118
  • 7