473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 15270
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
1
by: D | last post by:
i have something where i am parsing information into a csv file with created headers. the script gets replayed as it tests several user profiles. how can i get it to continue writing on the last...
1
by: James | last post by:
vb.net 2003 - console program i've read a array of machines and i wishes to display on console the machines name on the *same line.* How do i do this ? This is what i want say i got a text...
13
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
6
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.