RE: [PHP] Writting to files.?

From: Date: Thu, 05 Jul 2001 17:40:36 +0000
Subject: RE: [PHP] Writting to files.?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56347@lists.php.net to get a copy of this message
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 dread@texas.net -- 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.

« previous php.general (#56347) next »