Help using excel function in PHP
Posted: Wed Sep 08, 2010 5:55 pm
Hi,
I am using the Excel Rate(nper,pmt,pv,fv,type,guess) function to determine the interest rate based on the user's loan and payment criteria.
1) This works on my page:
$test = RATE(20*12,-950,100000)*12;
$test2 = number_format($test, 4, '.', ',')*100;
= 9.77%
compare with Excel:
=(RATE(20*12,-950,100000)*12) = 9.77%
2) When I increase nper to 30 (like below), however, I get the wrong result.
$test = RATE(30*12,950,-100000)*12;
= 8.0539952942838E-015
Excel, however, is okay:
=(RATE(30*12,950,-100000)*12) = 10.97%
Can someone tell me what I'm doing wrong? Thank you.
I am using the Excel Rate(nper,pmt,pv,fv,type,guess) function to determine the interest rate based on the user's loan and payment criteria.
1) This works on my page:
$test = RATE(20*12,-950,100000)*12;
$test2 = number_format($test, 4, '.', ',')*100;
= 9.77%
compare with Excel:
=(RATE(20*12,-950,100000)*12) = 9.77%
2) When I increase nper to 30 (like below), however, I get the wrong result.
$test = RATE(30*12,950,-100000)*12;
= 8.0539952942838E-015
Excel, however, is okay:
=(RATE(30*12,950,-100000)*12) = 10.97%
Can someone tell me what I'm doing wrong? Thank you.