...

View Full Version : line breaks



tycoon
07-18-2005, 11:35 AM
Hi...I have little problem on at moment....my problem is i'm trying to build a php data driven website.....the problem is when i display the data from the data.....its broken up my html table structure...is there anyway i can Maintain the line breaks

delinear
07-18-2005, 01:03 PM
If you mean linebreaks, for instance, like the ones created by <textarea> form fields ("\r", "\r\n" or "\n") then you can turn these into <br /> tags that will show up when you echo your HTML by using the nl2br() function, eg if you have some data in a variable called $data:

echo nl2br($data);

Fou-Lu
07-18-2005, 03:13 PM
I want to add this as well, nl2br function doesn't convert the new lines, it mearly adds a <br /> in front of it for html processing. This is most likely the function you are looking for, but beware of that aspect, I've seen a few sites that required the newlines to be destroyed (which requires either a replacement pattern (useless for this function), or a simple str_replace).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum