Is there any way I can empty a text file? Or rather just remove the first line?
Apr 28th, 2004 16:01
Mike Chavez, Umang Beri,
You can destroy the entries in a file using the "write" attribute:
#Opens the file for writing, but also destroys the contents of a
#file. Note that this also places the file pointer at the beginning of
$fh = fopen($myfile, "w");
You can also remove the first line by writing to a file in r+ mode or
rewinding the file to the beginning, then writing a blank line:
$fh = fopen($myfile, "r+");
I'm not quite sure this will work correctly (as I don't have access to
a php server right now and I'm doing it from the top of my head), but
the idea is that we want to write a blank line to the file and r+ and
rewind already places the pointer at the beginning of the file. Hope
that helps some...