【发布时间】:2018-09-18 15:55:00
【问题描述】:
我有一个数组数组,我正在循环以保存数据。
问题是有时数组非常大。
我想循环这个数组直到一个限制。
一旦超过了这个限制,它应该计算它还剩下多少来完成循环遍历所有数组,分块并完成它。
foreach ($offers as $offer){
//If have more the 8.000 then make more then one array_objects
$object_offer = new Offer();
$object_offer->setOfferSellerId($offer['sku']);
$object_offer->setQuantity($offer['quantity']);
$object_offers[] = $object_offer;
$i++;
if (count($offers) <= 8000 ){
if ($i >= count($offers)){
$this->invokeUpdateStockOffer($object_offers);
}
} else {
//Chunk it in some ways and save
$this->invokeUpdateStockOffer($object_offers);
}
}
请帮忙!
【问题讨论】:
-
你好,Gache,好像你要分批执行offer,8000个,对吗?