rololo
rololo

Reputation: 15

How to remove first and last <tr> tag from table - Simple HTML DOM Parser

Looks like I need to use $e->first_child () and $e->lastChild (), but its not working.

require_once '/simple_html_dom.php';
$html = file_get_html('http://example.com');

$table = $html->find('table');
echo $table->first_child();

<table>
    <tr>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
    </tr>
</table

Upvotes: 1

Views: 1077

Answers (1)

michal
michal

Reputation: 428

use this:

$table->find('tr',0);//first one
$table->find('tr',-1);//last one

if not works:

$html->find('tr',0);//first one
$html->find('tr',-1);//last one

Upvotes: 2

Related Questions