PHP: Do we have any command via which we can delete the contents of an file without opening it.

Posted by Rachel on Stack Overflow See other posts from Stack Overflow or by Rachel
Published on 2010-04-01T21:04:32Z Indexed on 2010/04/01 21:13 UTC
Read the original article Hit count: 232

Filed under:
|

Is there any way to remove the contents of an file in php, do we have any php command that does that, I know unlink but I do not want to delete the file instead I just want to remove the contents of that file.

I have an file which I pass while called a getCurrentDBSnap function, it takes in the file from /home/test/incoming folder and populates currentDB table state into the file using fputcsv and puts back file to /home/test/outgoing.

Currently file stays in incoming folder and when I can call the function getCurrentDBSnap it would take the file and override with latest state of DB into it.

Q: My question is, is it possible instead of overwriting the file, we can remove the content of file after ever getCurrentDBSnap such that file in incoming folder would be always empty ?

Hope it makes sense :)

© Stack Overflow or respective owner

Related posts about php

Related posts about csv