mermyphp Posted December 12, 2009 Share Posted December 12, 2009 I am a complete newb when it comes to php :'(. I have a set of hit counters that moniter the amount of hits on certain webpages. The hits are stored in a log file. such as indexcount.txt or aboutuscount.txt. I was wondering if there is a way to reset all of the counters to 0 in a single button click using php. Any help would be appreciated. Thanks mermyphp Quote Link to comment https://forums.phpfreaks.com/topic/184924-reset-multiple-counters/ Share on other sites More sharing options...
.josh Posted December 12, 2009 Share Posted December 12, 2009 well that depends on how they are being stored. If you have a bunch of text files that simply hold a single number at any given time, just do file_put_contents('filename','0'); for each one. However, if that is ALL these files are doing, you could have a single file with a serialized array, or alternatively, individual lines like so: index:0 aboutus:0 etc.. and then loop through each line and reset and write back to the single file. Quote Link to comment https://forums.phpfreaks.com/topic/184924-reset-multiple-counters/#findComment-976200 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.