title: Skip row if more than one cell is empty with PHP
body: <p>I have a PHP script that generates an HTML table from a CSV file.</p>
  
  <p>Right now if any cells are missing information, it skips the row. HOWEVER, I'd prefer if it skipped a row if more than one cell was missing. <strong>So if a row has 2 empty cells, it should skip.</strong></p>
  
  <p>I have marked it <code>//edit here</code> below but unsure how to acheive this.</p>
  
  <pre><code>&lt;?php
  $idsColumnsWanted = array(0,1,8,19);
  
  echo "&lt;table class='table table-bordered' id='example'&gt;\n\n";
  
  $f = fopen("users.csv", "r");
  $first_line = false;
  
  while (($line = fgetcsv($f)) !== false) {
      // Restart column index
      $i = 0;
      $row ="";
  
      if($first_line == false) {
          $row = "&lt;thead&gt;&lt;tr&gt;";
          $col = "th";
      } else {
          $row = "&lt;tr&gt;";
          $col= "td";
      }
  
      $is_empty = false;
      foreach ($line as $i =&gt; $cell) {
          // Skips all columns not in your list
          if (! in_array($i, $idsColumnsWanted)) continue;
  
          // edit here
          if ($cell !== '') {
              $row .= "&lt;".$col."&gt;" . htmlspecialchars($cell) . "   &lt;/".$col."&gt;";
          } else {
              $is_empty = true;
          }
          // Increase index
          $i++;
      }
  
      if($first_line == false)
          $row .= "&lt;/tr&gt;&lt;/thead&gt;";
      else 
          $row .= "&lt;/tr&gt;";
  
      $first_line = true;
  
      if ($is_empty) {
          continue;
      } else {
          echo $row;
      }
  }
  fclose($f);
  echo "\n&lt;/table&gt;";
  ?&gt;
  </code></pre>