Hi,

I'm creating a mortgage calculator for a client and he's given me a spreadsheet with the formulas in. The problem is that the formula uses an Excel function called PMT. This is the formula:

= - PMT ( R/12 , T*12 , A , 0 , 0 )

where R is the interest Rate (e.g. 10%)

T is the Term of the loan (e.g. 30 years)

and A is the Amount of the loan (e.g. 100,000)

The question is, how do I convert this into something I can put in PHP code to do the work on a webpage instead of in a spreadsheet??

Thanks

SWD

Please note: I had already asked this question but incorrectly put it in the Excel forum - it has since been moved to the PHP forum but I was concerned that it was getting the visibility that it would if I'd submitted it here straight away. I have requested that the existing question be removed. (

http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_21785434.html)

This will probably give you what you want, but slightly different from the Excel equivalent, so you'll have to play with it a little:

T = Term of the loan in years

R = Annual interest rate expressed as a Decimal (10% = 0.1)

A = Amount of the loan.

function PMT ($T, $R, $A ) {

$x = 1 / (1 + ( $R / 12 ) );

return ( ( 1 - $x ) * $A) / ($x * (1 - pow( $x, $T ) ) );

}

Note that I haven't tested this against the Excel PMT, I've just re-written an old C++ function I have to achive the same in PHP.