victorianrider Posted March 30, 2011 Share Posted March 30, 2011 Hey guys, I have a script that is run once a week to fetch some user info for a large number of accounts. The code I have now writes the info correctly, but I was wondering if there was an easy way to have the accountdata.txt file completely wiped before new updated info is written to it, as opposed to deleting it manually every week. $FileName = "accountdata.txt"; $f=fopen($FileName,"a+"); fwrite($f, $UserKey[$i]." ".$SigKey[$i]."\n"); $f=fclose; I could in theory just open the file and delete everything in it manually, save it and then run this script, but I'm always looking for more ways to make things efficient, and come a time when it's run more than once a week it'd be nice to have all that automated. So in summary, I need it to delete all data (if any) from the accountdata.txt file before it writes anything to it. Thanks. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 There's a very simple php function named unlink. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 If you want this all in one script, you could add a little code that finds the day of the week based on date, so if you want this to be done let's say on Sunday only, something like: if (date('N') == 7) unlink($FileName); Quote Link to comment Share on other sites More sharing options...
victorianrider Posted March 30, 2011 Author Share Posted March 30, 2011 If you want this all in one script, you could add a little code that finds the day of the week based on date, so if you want this to be done let's say on Sunday only, something like: if (date('N') == 7) unlink($FileName); Thankyou very much Quote Link to comment Share on other sites More sharing options...
victorianrider Posted March 30, 2011 Author Share Posted March 30, 2011 Hmm, I'm not seeing the Mark As Solved button, so I'll just state that it is solved Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 No worries, the solved mod has gone awol. We all long for its return Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.