Thanks for the response so far...

I'm still not sure on how to get the code to start on a new line in the file (yes they 
are text files). Say I wrote variable1 to line one how do I get it to write the next 
variable to line two?

Thanks
  ----- Original Message ----- 
  From: Don Read 
  To: James Bartlett 
  Cc: [EMAIL PROTECTED] 
  Sent: Thursday, July 05, 2001 6:40 PM
  Subject: RE: [PHP] Writting to files.?



  On 05-Jul-01 James Bartlett wrote:
  > Hi,
  > 
  > Anyone know how I can write and read to different lines in a file rather
  > than just adding to the text already on the first line of the file?
  > 
  > Thanks
  > 

  Assuming you're talking about text files:

  A. suck the whole thing up in memory, change it there, write it back out.
  B. open a temp, copy till the line of interest, write your change,
     copy remainder. mv/cp the temp to the original.
  C. read to line of interest, ftell(), suck remainder into memory.
     ftruncate(), fseek(), write your changes, write out the remainder.

  Regards, 
  -- 
  Don Read                                       [EMAIL PROTECTED]
  -- It's always darkest before the dawn. So if you are going to 
     steal the neighbor's newspaper, that's the time to do it.

Reply via email to