如何在phpquery中获取元素索引

时间:2014-10-22 09:31:04

标签: phpquery

我试图获取div的索引,其中包含'商店名称' 像:

$doc = phpQuery::newDocument($shops_page);
echo $shop_index = $doc->find(".shop_item:contains('Shop Name')")->index();

在JQuery $(".shop_item:contains('Shop Name')").index();中起作用

如何使用phpquery找到索引?

1 个答案:

答案 0 :(得分:0)

if ($doc->find(".shop_item:contains('Shop Name')")->length()){
$shop_index = $doc->find(".shop_item")->index(pq($doc->find(".shop_item:contains('.shop_item:contains('Shop Name')')")));
}