Is there any way to empty a file in php. Bascially I open a file and read in some values, then I feed the file into another function. I want to empty the file again for the next time.
There doesn't seem to be much functionality to fwrite() ? It doesn't give me the option of writing over the previous file contents.
Thanks
There doesn't seem to be much functionality to fwrite() ? It doesn't give me the option of writing over the previous file contents.
Code:
$filename = './templates/Classic/pad.tpl';
$fp = fopen($filename, "a");
flock($fp, LOCK_EX);
$string = $output;
if ( !fputs($fp, $string) ) { die("There was an error writing to the file 1"); }
$template->set_filenames( array('fckeditor' => './templates/Classic/pad.tpl') );
if ( !fwrite($fp, ' ') ) { die("There was an error writing to the file 2"); }
flock($fp, LOCK_UN);
fclose($fp);