Line breaks, them evil line breaks!

Any problem with PHP can be disscused here
Post Reply
pryj
Posts: 56
Joined: Tue Dec 21, 2004 1:06 pm

Line breaks, them evil line breaks!

Post by pryj »

Hi all,
I am running into a slight bit of a problem here. When an user uses textarea to enter data into MySQL, it stores the line breaks no problem. However, because of the way browsers render HTML, simply having them in there does not display them and I will probably need to convert them into
instead.

Is there any efficient way in doing this? Should I do that for every time something is pulled from the db? or should I do something prior to entering them into db? Any suggestions would be welcomed


tanaka
Posts: 195
Joined: Sat Mar 05, 2005 5:27 pm

Post by tanaka »

Every line break goes to database as "\n". To display them when requesting data from db you can use the function nl2br

eg:
echo nl2br($form_text_area);
L O L
Post Reply