有没有办法做到这一点?目前,我正在使用这种方法来遍历维基百科条目中具有 wikitable 类的每个表的 td。
foreach ($html->find('table.wikitable td') as $key => $info)
{
$text = $info->innertext;
}
但是,我想做的是为每个共享 wikitable 类名的表设置单独的循环。我不知道该怎么做。
有某种语法吗?我想做这样的事情
$first_table = $html->find('table.wikitable td', 0); // return all the td's for the first table
$second_table = $html->find('table.wikitable td', 1); // second one