title: simple_html_dom: why is the $html (string which contains the table to be parsed) empty?
body: <p>I have a string which has the HTML for an HTML table. I want to extract the data from the table as a dimensional array. Something like:</p>
  
  <pre><code>$Data = Array ( [0]=&gt; Array([0]=&gt;'Name', [1]=&gt;'Age', [2]=&gt;'CGPA'), 
                  [1]=&gt; Array([0]=&gt;'Bob', [1]=&gt;'24', [2]=&gt;'3'), 
                  [2]=&gt; Array([0]=&gt;'Alice', [1]=&gt;'23', [2]=&gt;'2'), 
                  [3]=&gt;Array([0]=&gt;'Amy', [1]=&gt;'22', [2]=&gt;'4') )
  </code></pre>
  
  <p>I tried a many methods but they kept giving me errors. Now I am working on using <em>"simple_html_dom"</em> and it seems easy enough to be understood. So I am going to use it.</p>
  
  <p>I am trying to use the <a href="https://stackoverflow.com/questions/3277687/how-to-print-cells-of-a-table-with-simple-html-dom">code given in the accepted answer of this question</a>. But it is giving me  <strong><code>Fatal error: Call to a member function find() on a non-object on line 34</code></strong></p>
  
  <p>I searched and found this solution, but when I put the check (commented out in the code given below), I get <strong><code>Parse error: syntax error, unexpected ''$html is empty!'' (T_CONSTANT_ENCAPSED_STRING) on line 35</code></strong>, <em>I have no clue why it is empty!</em> May be it is a string and not the object expected? But what do I do about it?</p>
  
  <p><strong>Code:-</strong></p>
  
  <pre><code>&lt;?php
  
  require('simple_html_dom.php');
  
  $html = 'Edit question&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="content"&gt;&lt;div class="formulation"&gt;&lt;h4 class="accesshide"&gt;Question text&lt;/h4&gt;&lt;input type="hidden" name="q18:1_:sequencecheck" value="1" /&gt;&lt;div class="qtext"&gt;&lt;table style="width: 454px; height: 269px;" border="1"&gt;&lt;caption&gt; &lt;/caption&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;Name&lt;/td&gt;
  &lt;td&gt;Age&lt;/td&gt;
  &lt;td&gt;CGPA&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Alice&lt;/td&gt;
  &lt;td&gt;24&lt;/td&gt;
  &lt;td&gt;4&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Bob&lt;/td&gt;
  &lt;td&gt;14&lt;/td&gt;
  &lt;td&gt;3&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Amy&lt;/td&gt;
  &lt;td&gt;33&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;p&gt; &lt;/p&gt;
  &lt;p&gt;Blah BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah?&lt;/p&gt;&lt;/div&gt;&lt;div class="ablock"&gt;&lt;div class="prompt"&gt;Select one:&lt;/div&gt;&lt;div class="answer"&gt;&lt;div class="r0"&gt;&lt;input type="radio" name="q18:1_answer" value="0" id="q18:1_answer0" /&gt;&lt;label for="q18:1_answer0"&gt;a. [1]ir[/1][2]34[/2]&lt;/label&gt; &lt;/div&gt;';
  
  //if (!empty($html)) {
      // get the table. Maybe there's just one, in which case just 'table' will do
      $table = $html-&gt;find('table');
  //} else {die '$html is empty!';}
  
  // initialize empty array to store the data array from each row, that is the array containing the rows (that is entire &lt;tr&gt; tag).
  $rowData = array();
  
  // loop over rows
  foreach($table-&gt;find('tr') as $row) {
  
      // initialize array to store the cell data from each row, that is the arrays containing data from &lt;td&gt; tags 
      $cellData = array();
      foreach($row-&gt;find('td.text') as $cell) {
  
          // push the cell's text to the array
          $cellData[] = $cell-&gt;innertext;
      }
  
      // push the row's data array to the 'big' array
      $rowData[] = $rowData;
  }
  print_r($rowData);
  </code></pre>