There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
black screen blue screen boot bsod computer connection crash css dell display driver drivers email error firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem ram router security slow software sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
PHP File Write


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
fongpn's Avatar
Member with 44 posts.
 
Join Date: Feb 2005
Experience: Intermediate
06-Mar-2007, 01:57 AM #1
PHP File Write
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?
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,252 posts.
 
Join Date: Oct 2006
06-Mar-2007, 09:15 AM #2
\n another line
fongpn's Avatar
Member with 44 posts.
 
Join Date: Feb 2005
Experience: Intermediate
06-Mar-2007, 03:35 PM #3
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 ?
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
06-Mar-2007, 06:13 PM #4
Quote:
Originally Posted by fongpn
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.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
06-Mar-2007, 06:37 PM #5
file() will put each line into an array element, so you can do $file[5] to get the 6th line.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:20 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.