469,275 Members | 1,675 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

How to write string in a file to the next line

How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.

Jul 17 '05 #1
4 15092
ma*****@hotmail.com wrote:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


\n only shows up in your browser when enclosed with <pre> tags.

Look at the source directly, use <pre> tags or use <br> instead of \n

JW

Jul 17 '05 #2
ma*****@hotmail.com wrote in news:1115044776.207438.318080
@o13g2000cwo.googlegroups.com:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


$user = trim($_POST['user']);
$add = trim($_POST['address']);

fwrite($ourFileHandle, "$user\n$add");

Jul 17 '05 #3
Good Man <he***@letsgo.com> wrote in news:Xns964A75DAB70FEsonicyouth@
216.196.97.131:
ma*****@hotmail.com wrote in news:1115044776.207438.318080
@o13g2000cwo.googlegroups.com:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


$user = trim($_POST['user']);
$add = trim($_POST['address']);

fwrite($ourFileHandle, "$user\n$add");


(assuming you were writing to a text file)
Jul 17 '05 #4
On Windows you need \r\n to produce a newline. Most editor is smart
enough to recognize \n, but not Notepad. You used to be able to open a
file in text mode, which turns on automatic translation of \n to \r\n.
But the PHP devs now are discouraging its use and, the last time I
tried, it didn't work.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by lawrence | last post: by
18 posts views Thread by jas | last post: by
1 post views Thread by James | last post: by
13 posts views Thread by Freaker85 | last post: by
24 posts views Thread by Bill | last post: by
6 posts views Thread by globalrev | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.