title: reading and formatting csv data using explode and arrays in php
body: <p><strong>The Objective</strong></p>
  
  <p>To read the csv file, and separate each line into an array. The first line (field names) displayed once, and then loop through the remaining data.</p>
  
  <p>I have this function to open and explode the csv file</p>
  
  <pre><code>$myFile = "csv.csv";
  $fh = fopen($myFile, 'r');
  $theData = fread($fh, filesize($myFile));
  fclose($fh);
  $csv = explode(",", $theData);
  </code></pre>
  
  <p>This is the CSV file in question</p>
  
  <pre><code>id,sub,type,regprice,natprice
  1,4,Team,40,75
  2,4,Individual,15,35
  3,4,Stunt Group,50,150
  4,4,Coed Partner Stunt,50,150
  </code></pre>
  
  <p>What i need to know how to do, is load the first line into an array separately, then loop through the remaining arrays in the following manner.</p>
  
  <pre><code>Array[0][0] - Array[0][1] - Array[0][2] - Array[0][3] - Array[0][4]
  -------------------------------------------------------------------
  Array[1][0] - Array[1][1] - Array[1][2] - Array[1][3] - Array[1][4]
  Array[2][0] - Array[2][1] - Array[2][2] - Array[2][3] - Array[2][4]
  Array[3][0] - Array[3][1] - Array[3][2] - Array[3][3] - Array[3][4]
  Array[4][0] - Array[4][1] - Array[4][2] - Array[4][3] - Array[4][4]
  </code></pre>