HTML table to php array
<p>--------------EDIT------------------------</p>

<p>So i am going with the DOM approach.  Here is what I have so far:</p>

<pre><code>  &lt;?php function getdata(){
    $contents = file_get_contents('internatdata.htm');
    //create a DOM based off of the string from the html table
     $DOM = new DOMDocument;
   $DOM-&gt;loadHTML($contents);

   //get all tr and td
   $items = $DOM-&gt;getElementsByTagName('tr');
   $tds = $DOM-&gt;getElementsByTagName('td');

   function tdrows($elements){
       $str = "";
       for ($ii =0; $ii &lt; $elements-&gt;length; $ii++){
            $str .= $elements-&gt;item($ii)-&gt;nodeValue . ",";


           }
          return $str;
       }

   for ($i = 0; $i &lt; $items-&gt;length; $i++){


       echo tdrows($tds) . "; &lt;br /&gt;";

       }

    } 
?&gt;
</code></pre>

<p>The issue I am having is that I only want to select the td's from each table row.   I am trying to achieve this with a nested loop.  unfortunately It is printing the text of every  tag on the page how ever many times as there are  tags.  how can i get it so its only printing the td of each tr and not every td on the dom?</p>

<hr>

<p>I need to use an html table as the source of my data because I don't have access to the database.  I figure to be able to query data from the html table I need create a function to  convert the table into an array, or a multidimensional array.   </p>

<p>I have the basic Idea I think but I need some help finishing the code to return an array based off the html table.  </p>

<p>Also If you have a better way of doing this other than converting the table to an array then please let me know</p>

<p>Here is the idea I had so far:</p>

<pre><code> &lt;?php
 function getdata(){

    $contents = file_get_contents('data.htm');
    //add delimiters (semicolon for a row and comma for a cell) ???

    $stripped = strip_tags($contents);

    //explode into an array based off the delimiters above ???


    } 
    ?&gt;
</code></pre>
