Jump to content

Reset multiple counters


mermyphp

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/184924-reset-multiple-counters/
Share on other sites

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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.