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?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-21 13:56:42
Original
1037 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template