Re: [PHP] rewrite one line in file

2001-03-29 Thread Jason Stechschulte

On Thu, Mar 29, 2001 at 03:05:09PM +0100, Peter Van Dijck wrote:
 How do I rewrite 1 line in a file? I got the filename and the linenumber. i 
 was playing around with fwrite but to find the line I had to do all sorts 
 of gymnastics, I'm sure there must be a more elegant way...
 thanks for any hints!

You have to do gymnastics to get a PHP script to work!!  I would love to
see this.  Also, I didn't realize there was anything more elegant that
gymnastics, well perhaps ballet I guess.  

Unless you search the web for a tool that someone else has written to
make things easier, you do have to do a few things to rewrite a line in
a file.  That is one of the reasons people use databases.  You could try
looking for programs that others have written to make file manipulation
easier, or you could post the portions of your code so we can see what
you are trying to do, and how you are doing it currently.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It's appositival, if it's there.  And it doesn't have to be there.
And it's really obvious that it's there when it's there.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] rewrite one line in file

2001-03-29 Thread David Robley

On Thu, 29 Mar 2001 23:35, Peter Van Dijck wrote:
 How do I rewrite 1 line in a file? I got the filename and the
 linenumber. i was playing around with fwrite but to find the line I had
 to do all sorts of gymnastics, I'm sure there must be a more elegant
 way...
 thanks for any hints!
 Peter

In a nutshell, you load the file into an array containing one line per 
element of the array.

You then work through the array until you find the line you want - if you 
know how many lines into the file it is you can of course directly 
reference the element (no_of_line -1 because the first array element is 
0).

Change the info you want.

Write the changed array back to the file. Coding is left as an exercise 
for the student :-)

-- 
David Robley| WEBMASTER  Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet| http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]