Ok, I tried this before, and it works - most of the time.
But sometimes, something goes wrong.
I read the file using
$contents=file("datafile.txt");
Then, I remove the line that I want to remove, and I write the data back using
$fp=fopen("datafile.txt","w");
foreach($contents as $line)
{fwrite($fp,$line);}
fclose($fp);
Sometimes, however, the file is opened afther the fopen() statement, but then it refuses to write to the file for whatever reason (for example PHP script time-out). In those cases, all the data that was in the file has disappeared. It does not happen often, but it does happen sometimes, for example when someone surfs to my site using anonymizer.
For this reason, I want to be able to delete a line without rewriting the entire file.
Or is there another way, to avoid this problem?
Kind regards
Boudewijn Verhaar