小编Rup*_*ric的帖子

每月分期付款

设想一个场景,每月租金为100,000,每个月底应支付。然后,租户决定支付350,000美元,以应付当月及以后的月份。由于我显然可以在此看到三个月半的时间,因此我应该如何分配这笔款项?这是我在PHP中尝试的方法,但我无法显示最后的50,000。

$rent       = 100000; // rent amount
$amountPaid = 350000; // amount paid by tenant

$length     = $amountPaid/$rent; // number of months paid for

for ($c = 1; $c <= $length; $c++) 
{
    $foreachMonth = $rent;
    assignRentFunction($c, $foreachMonth);
}

function assignRentFunction($count, $amt)
{
    echo "Month ".$count.': '.$amt."<br>";
}
Run Code Online (Sandbox Code Playgroud)

php arrays

6
推荐指数
3
解决办法
100
查看次数

标签 统计

arrays ×1

php ×1