Yep, generally in most languages, when you open a file for writing, unless you specify the mode as appending (a), the file pointer will be set to the begining of the file and thus the current contets of the file will be overwritten when you write to the file, and when you close the file the EOF marker will be placed at the end of the new content. So this has the effect of saying - open the file, truncate it to zero length by placing the file pointer at the begining of the file for writing (ie, discard the file's current contents). So for what you want to do, all you need to do is open the file in write mode (w), or read/write mode (w+)
PHP Code:
$fp = fopen("filename.txt", "w");
Bookmarks