I've just been reading a solved thread with this same title. The solution was nl2br. I was unaware of this function and have been using str_replace instead.

A problem arises however, when converting preformatted text, specifically a table. Either solution leaves a mass of space between text and a table due to all the new lines generated.

Is there a solution to this.

Recommended Answers

All 2 Replies

Thanks MitkOK, you've done it again.
My problem arose because I only have a text area for input. Consequently I formatted the output from my database with the str_replace equivalent of nl2br.
However, I already had a preformatted article in the database which contained a table. I got around the problem by updating the database, so that the table code was all on the same line.

I assume I'd have to use the trim function only on table code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.