title: Grab rows and then cells from a table
body: <p>I'm using the <a href="http://simplehtmldom.sourceforge.net/manual.htm" rel="nofollow noreferrer">Simple HTML Dom Parser</a> to grab a table (in the image) and then grab each <code>tr</code>. This outputs all the items in the row as one string.</p>
  
  <pre><code>$contents = $html-&gt;find('div[class=product-table]', 0);
  $titles = $contents-&gt;find('tr');
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5uflB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5uflB.png" alt="enter image description here"></a></p>
  
  <p>How can I create an array that keeps the data in rows but also allows me to output the individual cells? I want to be able to say there's 7 cells in a row (this could be flexible) and be able to output each individual cell in the row as variables (I need to do other stuff with these).</p>
  
  <hr>
  
  <pre><code>// Product Code Titles
  $contents = $html-&gt;find('div[class=product-table]', 0);
  $data = array();
  $rows = $contents-&gt;find('tr');
  $counter = 1;
  foreach ($rows as $key_row =&gt; $row) {
      // process rows here
      foreach ($row-&gt;find('td') as $key_cell =&gt; $cell) {
        $field_key = "field_5ae0882f9d6f9";
        $data[] = array(
          "column_title" =&gt; strip_tags($cell-&gt;innertext),
        );
        $counter++;
  
          // process each cell on the current row iteration
          // or whatever you need to do in each cell (calculations and whatnot)
          // $data[] = then push it inside an array (you can prolly use the keys and use it in `$data`)
      }
  } ?&gt;
  &lt;pre&gt;
  &lt;?php print_r($data); ?&gt;
  &lt;/pre&gt;
  &lt;?php update_field( $field_key, $data, $post_id );
  </code></pre>