PHP交付时间脚本


PHP delivery time script

我正在用PHP制作一个交付时间脚本。两道菜的配送时间应该是30分钟,更多的菜,每道菜加起来10分钟。

以下是我迄今为止所做的:

for ($i=30;$i>;$i=$i+10;) {
    echo "You have ordered " .$number. " dishes, and the delivery time is " .$time;
}

我不知道该怎么办。有人能帮帮我吗?如果它能以for循环的形式出现,那就太好了

谢谢!

您可以使用以下内容

$delivery = 30; //30 minutes by default
if($numDishes > 2){
    $extra = $numDishes - 2;
    $delivery = $delivery + ($extra * 10);
}

真的,这是基础。。。

$time = 30; // initial, could not be lower.
for($i=1;$i<$numDishes;$i++){
   // after the first one, add 10 to each other
   $time += 10;
}

编辑。。哦,我刚刚看到你在30分钟内有2个,那么最简单的方法是Wayne 的答案