gpt4 book ai didi

php查询。如何解析 表标记中的每第九个

转载 作者:行者123 更新时间:2023-12-01 07:58:07 25 4
gpt4 key购买 nike

如何使用 phpQuery 解析表标记中的每九个?我尝试这样:

require ('phpQuery/phpQuery.php');
$url = file_get_contents('http://127.0.0.1/filter/parser.html');
$document = phpQuery::newDocument($url);
$table=array();
foreach ($document->find('tr') as $tr){
$users = $tr->find('td,9')->text();
$table[$users]=true;
}

但是这不起作用。

最佳答案

您可以使用:eq()选择器:

$tr->find('td:eq(8)')->text()

.eq():

$tr->find('td').eq(8)->text()

第n个 child

$tr->find('td:nth-child(9n)')->text()

关于php查询。如何解析 <td> 表标记中的每第九个 <tr>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22347304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com