title: Parse html table data from DOMXPath
body: <p>I am scraping data from an external html table that is 100 rows by 3 columns. I want to parse the data into a 10x10 table where the data from each row is combined. Ex:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;info1&lt;/td&gt;
      &lt;td&gt;info2&lt;/td&gt;
      &lt;td&gt;info3&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;info4&lt;/td&gt;
      &lt;td&gt;info5&lt;/td&gt;
      &lt;td&gt;info6&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;info7&lt;/td&gt;
      &lt;td&gt;info8&lt;/td&gt;
      &lt;td&gt;info9&lt;/td&gt;
  &lt;/tr&gt;
  ...and so on
  </code></pre>
  
  <p>into </p>
  
  <pre><code>&lt;tr&gt;
     &lt;td&gt;info1&lt;br/&gt;info2&lt;br/&gt;info3&lt;/td&gt;
     &lt;td&gt;info4&lt;br/&gt;info5&lt;br/&gt;info6&lt;/td&gt;
     &lt;td&gt;info7&lt;br/&gt;info8&lt;br/&gt;info9&lt;/td&gt;
     ...7 more times
  &lt;/tr&gt;
  ...9 more times
  </code></pre>
  
  <p>I can output the data into a single column by using line breaks. I have absolutely no idea to do what I want to do above. Also I want to be able to style the data using css. Any help/direction is appreciated. Here is my code:</p>
  
  <pre><code>  $doc = new DOMDocument();
    $doc-&gt;loadHTML($html);
    libxml_clear_errors(); //remove errors for yucky html
  
    xpath = new DOMXPath($doc);
    $table = $xpath-&gt;query('//table[@id="idTable"]')-&gt;item(0);
    $rows = $table-&gt;getElementsByTagName("tr");
  
    foreach($rows as $row)
      {
        $cells = $row -&gt; getElementsByTagName('td');
        foreach ($cells as $cell) print $cell-&gt;nodeValue . "&lt;br/&gt;";
      }
  </code></pre>