在这里,我有2台机器,我需要为这些机器分配产品。每台机器有50个产品容量,所以如果我有100个产品,第一台机器上有50个产品,第二台机器上有50个产品,上述概念很好用,但是如果我的产品数量为150,则应该首先分配产品50至第一台机器,第二50至第二台机器,然后第三50至第一台机器,
$CountMachine=2;
$balanceQty=150;
$Loopcount=1;
foreach($FetchMachine as $i => $row){ //array has 2 records
//allocated 50 products
$balanceQty=$balanceQty-50;
if($Loopcount==$CountMachine && $BalanceQty>0){
$i=0; //herei got stuck , how to restart the loop from here, if the balance quantity is greater than 0 but loop excution is completed
}
}
$Loopcount++;
$CountMachine=2;
$balanceQty=150;
while($balanceQty>0){
foreach($FetchMachine as $i => $row){ //array has 2 records
//allocated 50 products
$balanceQty=$balanceQty-50;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句