Well, I have a loop issues and I'm not sure why....
All works but it's a non-stop loooooooooooooop:
<?PHP
//Loan Function to caculate loan amounts
function loan($paymentNum, $periodicPayment, $balance, $monthlyInterest){
$paymentInterest = round($balance * $monthlyInterest, 2);
$paymentPrincipal = round($periodicPayment - $paymentInterest, 2);
$newBalance = round($balance - $paymentPrincipal, 2);
print "
<tr>
<td>$paymentNum</td>
<td>\$".number_format($balance, 2)."</td>
<td>\$".number_format($periodicPayment, 2)."</td>
<td>\$".number_format($paymentInterest, 2)."</td>
<td>\$".number_format($paymentPrincipal, 2)."</td>
</tr>";
if($newBalance > 0){
$paymentNum++;
loan($paymentNum, $periodicPayment, $balance, $monthlyInterest);
}else{
exit;
}
} //end of loan() function
//Loan balanace
$balance = 200000.00;
//Loan Interest Rate
$interestRate = .0575;
//Monthly Interest Rate
$monthlyInterest = .0575 / 12;
//Term of loan Length
$termLength = 30;
//Number of Payments Per Year
$paymentsPerYear = 12;
//Payment Iteration
$paymentNumber = 1;
//Perform Beginning Calculations
$totalPayments = $termLength * $paymentsPerYear;
$intCalc = 1 + $interestRate / $paymentsPerYear;
$periodicPayment = $balance * pow($intCalc, $totalPayments) * ($intCalc - 1) / (pow($intCalc, $totalPayments) - 1);
$periodicPayment = round($periodicPayment, 2);
echo $totalPayments;
echo '<br/>';
echo $intCalc;
echo '<br/>';
echo $periodicPayment;
//start our table
echo "<table width='50%' align='center' border='1'>";
print "
<tr>
<th>PaymentNumber</th>
<th>Balance</th>
<th>Payments</th>
<th>Interest</th>
<th>Principal</th>
</tr>";
//call our recursive function
//loan($paymentNumber, $periodicPayment, $balance, $monthlyInterest);
print "<table>";
?>
Any/all help is appreciated...
Thanks,
j