i am working on a simple loan calculator, so simple that it’s not even working properly.
function calculatePayment($price, $down, $term)
{
$loan = $price - $down;
$rate = (4/100) / 12;
$month = $term * 12;
$payment = floor(($loan*$rate/1-pow(1+$rate,(-1*$month)))*100)/100;
return $payment;
}
echo calculatePayment(200000,0,30);
this output: 666.36
that would be great if the monthly loan payement is this (not that is the 666 number but low number hahah), my problem is this be higher.
why am i getting the this?
I just added put (1-pow(1+$rate,(-1*$month))) this because what is happening here is that $loan*$rate will be divided on 1 only then continue
The answer is
954.83