Page 1 of 1
EASY QUESTION
Posted: Mon Oct 28, 2002 6:21 pm
by lloydsmods
How do you execute a line break without resorting to the HTML tag <br>?
I've tried "\n" but that doesn't seem to work. It still strings the records together into one big line.
I need to output data from my MySQL database but I need each record to be on its own line and I can't use HTML.
Any suggestions?
Posted: Mon Oct 28, 2002 6:34 pm
by volka
<pre>text</pre> will preserve \n-linebreaks (pre-formatted)
nl2br() is also an option
Posted: Mon Oct 28, 2002 7:44 pm
by Tiimmy
The problem with
\n that you could be having might be because you're using
echo(), if you are; you'll need to use
print() instead.
Code: Select all
<?php
echo "Hello world\n"; // Won't work.
print "Hello world\n"; // Will work.
?>

Posted: Mon Oct 28, 2002 8:12 pm
by lc
Depending on your system.... you may want to try \r\n in stead of just \n that solved it for me on windoze systems.
Posted: Mon Oct 28, 2002 11:45 pm
by sam
Tiimmy the \n char should work with both echo and print, I just tested it with php 4.2.1,4.2.2 and 4.3RC2 on windows and 4.2.1 on redhat unix and it worked the same on all three.

Posted: Tue Oct 29, 2002 1:35 am
by Takuma
How can you execute a line break?
Posted: Tue Oct 29, 2002 2:42 am
by twigletmac
Why can't you use HTML?
Mac