PHP File Write

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

fongpn

Thread Starter
Joined
Feb 19, 2005
Messages
44
Hi everyone. I wanted to ask, how to write character into different lines. Take a look at the code below :-

<?php
$fd ='note.txt';
$fo = fopen($fd,'w');

$abc ='texting';
fwrite($fo,$abc);
?>

The output will be in note.txt will be
"texting"
in one line

The question here is, how am i going to write into the note.txt another line? Anyone can help me?
 

fongpn

Thread Starter
Joined
Feb 19, 2005
Messages
44
Thanks a lot MMJ! By the way, if I am using 'r' function to read it, I can read using filesize($fd) and using the fgets($fo) function. The filesize function read all character meanwhile the fgets function read the first line until it see the \n break. Can I assign it to read specific line? I mean i just wanted it to read line 6 in my $fo ?
 
Joined
Mar 14, 2006
Messages
941
fongpn said:
Thanks a lot MMJ! By the way, if I am using 'r' function to read it, I can read using filesize($fd) and using the fgets($fo) function. The filesize function read all character meanwhile the fgets function read the first line until it see the \n break. Can I assign it to read specific line? I mean i just wanted it to read line 6 in my $fo ?
Hm.. I don't think you can read a specific line, you'll probably need a database for that.
 
Joined
Jul 8, 2002
Messages
14,681
file() will put each line into an array element, so you can do $file[5] to get the 6th line.
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top