// Begin Loan 1 amortization table output //
for ($i = 0; $i < $totalPeriods1 ; $i++)
{
$principle = $loanAmount1 ;
$monthlyInterest = ( $periodicRate1 * $principle ) ;
$monthlyPrinciple = ( ( $principle - $payment1 ) + $monthlyInterest ) ;
$monthlyPaid1 = ( $principle - $monthlyPrinciple ) ;
$loanAmount1 = $monthlyPrinciple;
$year1 = $year++;
$totalInterestPaid = ( $monthlyInterest + $totalInterestPaid ) ;
// Show Loan 1 amoritzation table //
?>
|
echo "Balance Mo $year1 "; ?> | echo sprintf("%01.2f", $monthlyPrinciple) ; ?> |
|
Int Paid | echo sprintf("%01.2f", $monthlyInterest) ; ?> |
|
Prin Paid | echo sprintf("%01.2f", $monthlyPaid1) ; ?> |
|
Accrued Int | echo sprintf("%01.2f", $totalInterestPaid) ;?> |
}
?>
|
// Begin Loan 2 amortization table output //
for ($i2 = 0; $i2 < $totalPeriods2 ; $i2++)
{
$principle2 = $loanAmount2 ;
$monthlyInterest2 = ( $periodicRate2 * $principle2 ) ;
$monthlyPrinciple2 = ( ( $principle2 - $payment2 ) + $monthlyInterest2 ) ;
$monthlyPaid2 = ( $principle2 - $monthlyPrinciple2 ) ;
$loanAmount2 = $monthlyPrinciple2 ;
$year2 = $year3++ ;
$totalInterestPaid2 = ( $monthlyInterest2 + $totalInterestPaid2 ) ;
// Show Loan 2 amoritzation table //
?>
|
echo "Balance Mo $year2 "; ?> | echo sprintf("%01.2f", $monthlyPrinciple2) ; ?>
|
|
Int Paid | echo sprintf("%01.2f", $monthlyInterest2) ; ?>
|
|
Prin Paid | echo sprintf("%01.2f", $monthlyPaid2) ; ?>
|
|
Accrued Int | echo sprintf("%01.2f", $totalInterestPaid2) ;?>
|
}
?>
|
// Show Loan 1 and Loan 2 amoritzation tables added together. //
for ($i3 = 0; $i3 < $totalPeriods2 ; $i3++)
{
$principle3 = $loanAmount2 ;
$monthlyInterest3 = ( $periodicRate2 * $principle2 ) ;
$monthlyPrinciple3 = ( ( $principle2 - $payment2 ) + $monthlyInterest2 ) ;
$monthlyPaid3 = ( $principle2 - $monthlyPrinciple2 ) ;
$loanAmount3 = $monthlyPrinciple2 ;
$year2a = $year3a++ ;
$totalInterestPaid3 = ( $monthlyInterest2 + $totalInterestPaid2 ) ;
$principle4 = $loanAmount1 ;
$monthlyInterest4 = ( $periodicRate1 * $principle ) ;
$monthlyPrinciple4 = ( ( $principle - $payment1 ) + $monthlyInterest ) ;
$monthlyPaid4 = ( $principle - $monthlyPrinciple ) ;
$loanAmount4 = $monthlyPrinciple;
$totalInterestPaid4 = ( $monthlyInterest + $totalInterestPaid ) ;
$totalPrinciple = $monthlyPrinciple3 + $monthlyPrinciple4;
$totalMonthlyInterestPaid = $totalInterestPaid3 + $totalInterestPaid4;
$totalMonthlyPaid = $monthlyPaid3 + $monthlyPaid4;
$totalMonthlyInterest = $monthlyInterest3 + $monthlyInterest4;
// Build the arrays to add to Loans //
$cnt_loan1 = 0;
$cnt_loan2 = 0;
$cnt_loan3 = 0;
$cnt_loan4 = 0;
$cnt_loan1++;
$cnt_loan2++;
$cnt_loan3++;
$cnt_loan4++;
$loan2Array = array( array($cnt_loan2, $totalPrinciple),
array($cnt_loan1, $totalMonthlyInterest),
array($cnt_loan3, $totalMonthlyPaid),
array($cnt_loan4, $totalMonthlyInterestPaid)
);
/* for ($row = 0; $row < 4; $row++)
{
for ($col = 1; $col < 2; $col++)
{
echo $loan2Array[$row][$col] ?> ;
}
} */
// Show both amoritzation table added together //
?>
|
echo "Balance Mo $year2a "; ?> | echo sprintf("%01.2f", $totalPrinciple) ; ?>
|
|
Int Paid | echo sprintf("%01.2f", $totalMonthlyInterest) ; ?>
|
|
Prin Paid | echo sprintf("%01.2f", $totalMonthlyPaid) ; ?>
|
|
Accrued Int | echo sprintf("%01.2f", $totalMonthlyInterestPaid) ;?>
|
}
}
?>
|
|