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

From: Date: Wed, 22 Aug 2001 09:38:51 +0000
Subject: How can I insert the data into the begining of a text file
Groups: php.general 
Request: Send a blank email to php-general+get-63883@lists.php.net to get a copy of this message
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??

« previous php.general (#63883) next »