Re: appending to the begining of a file

From: Date: Mon, 06 Nov 2000 20:49:26 +0000
Subject: Re: appending to the begining of a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23978@lists.php.net to get a copy of this message
Basically, NO. You will need to open the existing file for read, a new file for output, put your new records at the start of the new output file, then copy the rest of the records from the old file to the new file. You would then close both files, delete the old file and rename the new file to the old file's name. At least to the best of my knowledge about both UNIX/Linux & Windows. There is no way to "prepend" information to the start of a file. John On Mon, 6 Nov 2000, Dusty Cohen wrote: > > Is there an append mode that starts at the BEGINNING of a file? r+ will write over anything > that's already there. For instance, if I have the file: > All that glitters is gold > And she's buying a stairway to heaven. > > and I open the file with r+, and 'add' the text: > There's a lady who's sure > > Then the resulting file is: > There's a lady who's sure > And she's buying a stairway to heaven. > > But I want: > There's a lady who's sure > All that glitters is gold > And she's buying a stairway to heaven. > > Was this clear? Anybody have any ideas? > > Dusty > ----------------------------------------------- > http://TerribleHost.com 50mg/php/mySQL $10month > ----------------------------------------------- > > >

« previous php.general (#23978) next »