title: Visit counter stored to a file using codeigniter
body: <p>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.</p>
  
  <p>I was trying to use the <a href="http://ellislab.com/codeigniter/user-guide/helpers/file_helper.html" rel="nofollow noreferrer">file helper</a> and the <a href="http://ellislab.com/codeigniter/user-guide/helpers/string_helper.html" rel="nofollow noreferrer">string helper</a> 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</p>
  
  <p>this is the code so far ...</p>
  
  <p>namespace libraries;</p>
  
  <pre><code>class VisitCounter {
  
      function __construct() {
          $this-&gt;load-&gt;library('file');
          $this-&gt;load-&gt;helper('string');
      }
  
      function trackVisit(){
          $file= read_file('./visits.txt');
  
          if ( ! write_file('./visits.txt', $file)){
              echo 'Unable to write the file';
          }
      }
  }
  </code></pre>
  
  <p>Any Ideas, I need to know how to split the string or if someone has a better approach.</p>