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]

Reply via email to