I'm trying to write some code to erase the last 50 chars of a text file and then appent text to it. This is what I have so far but it seems buggy:
$fp = fopen ($file_name, "a+");
fseek($fp, -50, SEEK_END);
ftruncate ($fp, -50);
fwrite($fp, $new_data);
I think that I had it working at one point but now it rewrites the erases most of the file.
Any ideas?