Data that is stored in my mysql database, has the breaks of text input properly, but when retrieved the data no longer has the breaks, and everything is displayed as one string without any <br>
. Any idea why this would occur?
The data column is the format text
, for example: in a table there is:
hey
how
do
you
do
After retrieving the data ill echo $mesarray[0][message];
and the result is:
hey how do you do
I want the line breaks to appear, but they dont.
The reason is because HTML does not understand line breaks. They need <br />
tags to break lines.
There is a function called nl2br() which can be used to convert new lines to <br>
echo nl2br($mesarray[0][message]);