Added: Jun 10, 2002
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Very handy to have around. you have a text file that is huge and want to append to it. but you don't want the new data to go clear to the bottom of the file. Well this script will let you do just the opposite. It will let you write to the file but put the new data at the begining and the old data at the end.
$file_name = "nieuws.txt";
#open and place the $fp point at the beginning of the file
#prevent the file from being messed up.
#read in the old data
$old_data = fread($fp, filesize($file_name));
# reset the file pointer to the start of the file so that the fwrite overwrites the original data
#concat the new data then the old data
fwrite($fp, "new data" . $old_data);
#release the lock, fclose can also do this
#close the file
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.