PHP code example of kaurikk / loan-payment-calculator
1. Go to this page and download the library: Download kaurikk/loan-payment-calculator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kaurikk / loan-payment-calculator example snippets
// $paymentAmountCalculator is instance of PaymentAmountCalculatorInterface
// $interestAmountCalculator is instance of InterestAmountCalculatorInterface
$calculator = new PaymentsCalculator($paymentAmountCalculator, $interestAmountCalculator);
$periods = $paymentPeriods; // must be instance of PaymentPeriodsInterface
$principal = 2000;
$interestRate = 20;
$calculationMode = 1; // see PaymentPeriodsInterface for available modes
$futureValue = 0; // Expected value after loan end, usually 0
$payments = $calculator->calculatePayments($periods, $principal, $interestRate, $calculationMode, $futureValue);