Home > Article > Backend Development > How to get elements by layer in php simple_html_dom?
I only want to get the TR of the first level table, that is, COUNT equals 1. How should I write it correctly?
<code>$html = new simple_html_dom(); $html->load('<table><tr><td>11111</td><td>22222<table><tr><td>3333</td></tr></table></td></tr></table>'); $trs = $html->find('table',0)->find('tr'); //我想得到的是该table的直属tr,亲儿子。 $count = count($trs); echo $count;</code>