我对url进行了xpath查询并获取了一组元素。 现在我需要为每个项目获得大量物品的集合。 在最近的代码中,我只有一个庞大的。帮我正确组织大量。
//Queries by classNames
$queryItem = $xpath->query('//div[@class="catalog__item"]');
foreach ($queryItem as $goodsItem) {
$result = array (
"goodsItem" => array (
"queryName" => $xpath->query('//a[@class="goods__title"]', $goodsItem),
"queryPrice" => $xpath->query('//span[@class="price_block__cur-price"]', $goodsItem),
"queryDiscount" => $xpath->query('//span[@class="price_block__old-price"]', $goodsItem),
"queryImglink" => $xpath->query('//img[@class="catalog__item__image"]/@src', $goodsItem),
"queryDesription" => $xpath->query('//div[@class="catalog__item__text"]/p', $goodsItem)
)
);
}
var_dump($result);