Hi I’m wondering how to do just a simple visit counter that stores the information into a file the format could be something like: Date | # Visits, this is just a POC that I’m trying to do here nothing complicated I just want to get use to this framework.
I was trying to use the file helper and the string helper to read the file and then subtract the date or split the content and use a loop to iterate the and update the current date
this is the code so far …
namespace libraries;
class VisitCounter {
function __construct() {
$this->load->library('file');
$this->load->helper('string');
}
function trackVisit(){
$file= read_file('./visits.txt');
if ( ! write_file('./visits.txt', $file)){
echo 'Unable to write the file';
}
}
}
Any Ideas, I need to know how to split the string or if someone has a better approach.
I created a model for doing that:
Heres the structure: