title: Parse html table using file_get_contents to php array
body: <p>I am trying to parse the table shown <a href="http://flow935.com/playlist/flowhis.HTM" rel="noreferrer">here</a> into a multi-dimensional php array. I am using the following code but for some reason its returning an empty array. After searching around on the web, I found <a href="http://blog.mspace.fm/2009/10/14/parse-an-html-table-with-php/" rel="noreferrer">this site</a> which is where I got the parseTable() function from. From reading the comments on that website, I see that the function works perfectly. So I'm assuming there is something wrong with the way I'm getting the HTML code from file_get_contents(). Any thoughts on what I'm doing wrong?</p>
  
  <pre><code>&lt;?php
  
  $data = file_get_contents('http://flow935.com/playlist/flowhis.HTM');
  
  function parseTable($html)
  {
    // Find the table
    preg_match("/&lt;table.*?&gt;.*?&lt;\/[\s]*table&gt;/s", $html, $table_html);
  
    // Get title for each row
    preg_match_all("/&lt;th.*?&gt;(.*?)&lt;\/[\s]*th&gt;/", $table_html[0], $matches);
    $row_headers = $matches[1];
  
    // Iterate each row
    preg_match_all("/&lt;tr.*?&gt;(.*?)&lt;\/[\s]*tr&gt;/s", $table_html[0], $matches);
  
    $table = array();
  
    foreach($matches[1] as $row_html)
    {
      preg_match_all("/&lt;td.*?&gt;(.*?)&lt;\/[\s]*td&gt;/", $row_html, $td_matches);
      $row = array();
      for($i=0; $i&lt;count($td_matches[1]); $i++)
      {
        $td = strip_tags(html_entity_decode($td_matches[1][$i]));
        $row[$row_headers[$i]] = $td;
      }
  
      if(count($row) &gt; 0)
        $table[] = $row;
    }
    return $table;
  }
  
  $output = parseTable($data);
  
  print_r($output);
  
  ?&gt;
  </code></pre>
  
  <p>I want my output array to look something like this:</p>
  
  <pre>
  1
  --> 11:33AM
  --> DEV
  --> IN THE DARK
  
  2
  --> 11:29AM
  --> LIL' WAYNE
  --> SHE WILL
  
  3
  --> 11:26AM
  --> KARDINAL OFFISHALL
  --> NUMBA 1 (TIDE IS HIGH)
  </pre>