How to calculate EMI using PHP program

EMI Calculator

EMI stand for Equated Monthly Installment. It is one part of the equally divided monthly outgoes to clear off an outstanding loan within a stipulated time frame. The borrower pays this fixed amount to a lender at a specified date each calendar month.

EMI Calculator formula

EMI Calculator formula
EMI Calculator formula

P = Principal Amount (Loan Required or Sanctioned)

R = Rate of interest per annum

  • For Eg.ROI = 9.25%

Then R = 9.25/(12*100) = 0.007708333

N = Repayment Period ( Total number of months or No of installments)

  • For Eg. N = 2 Years

Then N = 2 * 12 = 24 months

PHP program to calculate EMI

In this program, we got the input values such as principal amount, rate of interest per annum and Repayment period in Years. Before calculate the EMI, the program calculates the Rate of interest for one month using R = 9.25/(12*100) = 0.007708333 .

Next it has converted the Repayment period from years to months t = 2 * 12 = 24 months. Then the function emi_calculator has calculated the EMI using the following formula

EMI = [P x R x (1+R)^N]/[(1+R)^N-1]

Output of this program

Recommended Articles