tags:

views:

32

answers:

3

Hi guys, I have a longtext in a database. It looks fine from php_mayadmin, but when I echo it out to a page, it loose all formatting, i.e. no new lines, all in one chunk. Any ideas? :)

Thanks!

+1  A: 

It's because phpMyAdmin is using wordwrap().

Tom
+2  A: 

Probably because the linebreaks are \n and html wants <br /> so use nl2br()

Iznogood
WORKS! THANKS! :)
@user296516 How about accepting my answer then? :)
Iznogood
+1  A: 

The string is stored with newlines representing the linebreaks. When you echo that, it just echos it into the source, so there are line breaks in the code. However, you want to have <br /> tags where the line breaks would be. PHP's nl2br function should work converts linebreaks into HTML <br> tags - that should do what you want.

Alex Zylman