views:

47

answers:

2

im coding a guestbook and i want new lines and spaces to be shown when i show the posts?

when i post a thread now everything is shown on one line.

help!

+2  A: 

Use this function:

http://php.net/manual/en/function.nl2br.php

nl2br() will convert new lines into <br/> tags, so you will get new lines.

Alexandru Luchian
+3  A: 

Use nl2br(). Basically it's prepending every newline character with <br />.

Tatu Ulmanen
Just a nit: there is no need for a space before the "/".
Loadmaster
Needed or not that's what nl2br() returns ;) http://php.net/nl2br: "Returns string with '<br />' or '<br>' inserted before all newlines. "
VolkerK
nl2br() returns <br /> for legacy user-agent compatibility: http://stackoverflow.com/questions/1659208/why-br-and-not-br/1659222#1659222
micahwittman
Actually, the space before "/" is/was needed for legacy support of some older browsers, but not nowadays.
Tatu Ulmanen