title: Output CSV to HTML using PHP
body: <p>I have a very basic question it seems very simple but I am getting stuck on the concept.</p>
  
  <p>I am trying to output a csv to html using php and this is the code I want to output as.</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-1"&gt;
      &lt;div class="in"&gt;
        &lt;p class="description"&gt;FIRST CELL OF ROW HERE&lt;/p&gt;
        &lt;p class="town"&gt;SECOND CELL OF ROW HERE&lt;/p&gt;
        &lt;p class="city"&gt;THIRD CELL OF ROW HERE&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and here is my PHP</p>
  
  <pre><code>&lt;?php
  
  echo "&lt;html&gt;&lt;body&gt;&lt;table&gt;\n\n";
  $f = fopen("test.csv", "r");
  while (($line = fgetcsv($f)) !== false) {
      echo "&lt;div class='row'";
      foreach ($line as $cell) {
          echo "&lt;div class='col-1'&gt;&lt;div class='in'&gt;";
          echo "&lt;p class='description'&gt;" . htmlspecialchars($cell) . "&lt;/p&gt;";
          echo "&lt;p class='address'&gt;" . htmlspecialchars($cell[1]) . "&lt;/p&gt;";
          echo "&lt;p class='town'&gt;" . htmlspecialchars($cell[2]) . "&lt;/p&gt;";
          echo "&lt;/div&gt;&lt;/div&gt;";
      }
      echo "&lt;/div&gt;";
  }
  fclose($f);
  echo "\n&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated as I can't seem to get the second and third row outputting correctly in there corresponding paragraph tags.</p>