What's the easiest way to pre-pend a file with fopen (or another way) so that the newest data is put at the beginning of the file?
Thaks,
D
prepend a text file with out truncating the file to zero len
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$curData = file_get_contents($FILE);
file_put_contents($FILE, $newData . $curData);note this is PHP 5 dependent (file_put_contents()) but you can use fopen(), fwrite(), and fclose() to mimic this function in PHP < version 5