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!
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!
Probably because the linebreaks are \n and html wants <br />
so use
nl2br()
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.