Home >Backend Development >PHP Tutorial >How to get elements by layer in php simple_html_dom?

How to get elements by layer in php simple_html_dom?

WBOY
WBOYOriginal
2016-09-21 13:56:42998browse

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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn