Re: How can I insert the data into the begining of a text file

From: Date: Wed, 22 Aug 2001 16:14:23 +0000
Subject: Re: How can I insert the data into the begining of a text file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-63927@lists.php.net to get a copy of this message
I have try this but, PHP just overwrite the prevoius content, and write the new message into the file. But I want to INSERT the new message into the head of a file. Or , I did a wrong thing again?? My code is like now. $fp = fopen ( $HTTP_SERVER_VARS['DOCUMENT_ROOT']."/log/debug_message.txt", "r+" ); fputs ( $fp, "\nDebug message from : $PHP_SELF at ".strftime("%T on %D")."\n" ); fputs ( $fp, "$message\n\n" ); fclose ( $fp ); "Niklas lampén" <niklas.lampen@publico.fi> ????? news:NPEFKEPHNLKEPEOLHPKNIENPCCAA.niklas.lampen@publico.fi... > Use $fp = fopen($file, "r+"); > > PHP Manual would have told you this. > > > Niklas > > -----Original Message----- > From: Zenith [mailto:nixstyle@hongkong.com] > Sent: 22. elokuuta 2001 12:39 > To: php-general@lists.php.net > Subject: [PHP] How can I insert the data into the begining of a text > file > > > I orginal have a function like the following... > > $fp = fopen $HTTP_SERVER_VARS['DOCUMENT_ROOT']."/log/debug_message.txt", > "a" ); > fputs ( $fp, "\nDebug message from : $PHP_SELF\n" ); > fputs ( $fp, "\t$message\n\n" ); > fclose ( $fp ); > > But I found that, the result is, all message is append to the end of a file. > Can I insert the text into the begining of the file?? > > I think read all the text from the file first, arrang the string variable, > so that the new message can insert, would be a solution. But is it stupid to > do so?? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#63927) next »