To truncate the data in a file, you can use the truncate function:
truncate($file, $new_size)
The $file value can be either a file name or a file handle.
The $new_size value is usually 0, to eliminate all data in a file.
Related examples in the same category