Page 1 of 1

prinft - nl2br

Posted: Tue Mar 16, 2004 11:57 pm
by allelopath
I have these 2 lines:

printf ("id: %s Date: %s First Name: %s Last Name: %s\n",
$row[0], $row[1], $row[2], $row[3]);
print ("\n");

the newlines don't work.
i see there is a function nl2br to convert newlines to <br>
how do i use this?

Posted: Wed Mar 17, 2004 12:04 am
by Goowe
before each of your \n thingers put the <BR> ;)

Posted: Wed Mar 17, 2004 1:31 am
by m3mn0n
allelopath wrote:the newlines don't work.
If you use Windows, it shouldn't.

Windows seperates the lines like so: \r\n

So try that, if not, do what I like to do and simply add <br> (or <br />). It's a bit more universal than line breaks. ;)
allelopath wrote:i see there is a function nl2br to convert newlines to <br>
how do i use this?
This is mainly used for changing line breaks in submitted data (such as this reply box in the forum, that I'm currently typing in). If you run a field such as $_POST['messagebox'] through [php_man]nl2br[/php_man](), every instance that someone hit enter within that box, the function will replace it with <br>. More info at the manual page.
Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions before 4.0.5 will return string with '<br>' inserted before newlines instead of '<br />'.

Posted: Wed Mar 17, 2004 10:03 am
by allelopath
thanks for the comments