title: Looping through files, one file processes, then that's it, no error reporting
body: <p>So I have a problem with a script I'm working on. I have a folder full of JSON files called roster0.json, roster1, etc. etc. </p>
  
  <pre><code>$dir = "responses/";
  $files = glob($dir . "roster*");
  $failed = array();
  $failcnt = 0;
  
  if (isset($files)) {
     $data = null;
     for ($i = 0; $i &lt; count($files); $i++) {
          $data = json_decode(utf8_decode(file_get_contents($files[$i])));
          if(isset($data)){
              // Process stuff
  </code></pre>
  
  <p>When I var_dump($files) I get an array with over 100 paths "responses/roster0.json".
  When I test $data I get a proper array of data.
  However, once the loop goes to the next file, it never loads it, and never processes it. </p>
  
  <p>Here's the crazy part. If I change the start of the for loop, e.g. $i = 20. It will load the 21st file in the directory and parse it and insert it into the db properly!</p>
  
  <p>Ignoring the failcnt stuff at the bottom, here's the current version of the script in it's entirety. <a href="http://pastebin.com/yqyKi5Ag" rel="nofollow">http://pastebin.com/yqyKi5Ag</a></p>
  
  <p>PS - I have full WARNING/ERROR reporting on in PHP and not getting any error messages...HELP! Thanks!</p>