title: Trouble understanding a PHP code sample
body: <p>I've been looking around to see if anyone else has dissected this code already, but that has proven to be futile. I'm having some trouble understanding what's happening in this php code sample from <a href="http://php.net/manual/en/function.fgetcsv.php" rel="nofollow">here</a>.</p>
  
  <p>I'm still currently very new to programming and PHP as a whole so I'm hoping someone can give me a clean explanation (I have read the documentation, but I still fail to fully understand the code)</p>
  
  <p>I'm currently tackling on a project to convert an uploaded CSV file into an array and then into a database. The sample code is below:</p>
  
  <p><strong>Example #1 Read and print the entire contents of a CSV file</strong></p>
  
  <pre><code>&lt;?php
  $row = 1;
  if (($handle = fopen("test.csv", "r")) !== FALSE) {
      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
          $num = count($data);
          echo "&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n";
          $row++;
          for ($c=0; $c &lt; $num; $c++) {
              echo $data[$c] . "&lt;br /&gt;\n";
          }
      }
      fclose($handle);
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>I guess my problem really is with understanding the <code>fgetcsv</code> method, but if someone could provide me with a breakdown it would really be appreciated.</p>