how to iterate through arrays from a file
<p>I have a simple html file containing this content.</p>

<pre><code>&lt;table border="1"&gt;
    &lt;tr&gt;
        &lt;td&gt;Name&lt;/td&gt;
        &lt;td&gt;City&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Greg House&lt;/td&gt;
        &lt;td&gt;Century City&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Dexter Morgan&lt;/td&gt;
        &lt;td&gt;Miami&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I have this script:</p>

<pre><code>include_once('simple_html_dom.php');

//$html = file_get_html('');
$html = file_get_html('http://localhost/path2mylocalfile/test1.html');

// first check if $html-&gt;find exists
if (method_exists($html,"find")) 
{
    // then check if the html element exists to avoid trying to parse non-html   
    if ($html-&gt;find('html')) 
    {

        foreach ($html-&gt;find('table') as $table)
        {

            // loop over rows
            foreach($table-&gt;find('tr') as $row) 
            {
                // initialize array to store the cell data from each row
                $rowData = array();

                foreach($row-&gt;find('td.text') as $cell) 
                {
                    // initialize array to store the cell data from each col
                    //$colData = array();                   

                    // push the cell's text to the array
                    $rowData[] = $cell-&gt;innertext;
                }

                if ($rowData) $theData[]=$rowData;

            }
            //print_r($theData);        

        }
    }
}

//Show array    
//foreach ($colData as $colItems)
//{
      foreach ($rowData as $rowItems)
          {
              echo "$rowItems&lt;br /&gt;&lt;br /&gt;";
          }
          //print_r($theData);
//}
</code></pre>

<p>If I only use the <code>$rowData</code> loop I only get the last name and city out, so I've tried to add the <code>$colData</code> loop, but when I use this nothing comes on the screen.</p>

<p>How can I loop through rows and cols and show both name and cities?</p>
