Page 1 of 1

Can't figure out how to "add" to a text file

Posted: Tue Jan 23, 2007 5:58 am
by djwk
Ok

Here's my code:
$1 = $1 + "\n".$2;

And here's the output
07

I want the output to be:
0
7

I just can't figure out what I'm doing wrong, anyone?

Posted: Tue Jan 23, 2007 6:13 am
by volka
This output is displayed in a html browser?
Then you need <br /> instead of \n
You might be interested in http://de3.php.net/nl2br

Posted: Tue Jan 23, 2007 6:14 am
by djwk
Ahh sorry, I hadn't actually saved it to a text file.. sorry for wasting your time

Posted: Tue Jan 23, 2007 6:15 am
by aaronhall
Or stick <pre> tags around the output if you must use \n

Posted: Tue Jan 23, 2007 8:12 am
by djwk
I've done it to a file now and it's not doing a new line

It has the value of $1 then the little square symbol thing then the value of $2...


Any help?

Posted: Tue Jan 23, 2007 8:18 am
by feyd
\r\n or try the PHP_EOL constant (if you are running PHP 4.3.10+ or PHP 5.0.2+)

Posted: Tue Jan 23, 2007 8:20 am
by djwk
I've fixed it now, nevermind, thanks for all your help :)

Posted: Tue Jan 23, 2007 12:57 pm
by Kieran Huggins
or set the header to text/plain...

:rofl: we can't stop!!!!!