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.
Help using excel function in PHP
Moderator: General Moderators
Re: Help using excel function in PHP
I would guess that RATE() is doing something wrong.
Re: Help using excel function in PHP
The PHP manual doesn't show any such function as "RATE()". You can't use a function from a totally different program. Apparently your script defines a PHP function called RATE(). Apparently that's where your answer lies.
Re: Help using excel function in PHP
Hi,
Thank you both for responding. But several other excel functions work, and even this Rate() function works as long as $nper doesn't exceed 240. Does anyone have a work-around or PHP script that will enable me to determine the interest rate on a loan amount based on payment periods, payment, and loan amount? It would be most appreciated.
Thank you both for responding. But several other excel functions work, and even this Rate() function works as long as $nper doesn't exceed 240. Does anyone have a work-around or PHP script that will enable me to determine the interest rate on a loan amount based on payment periods, payment, and loan amount? It would be most appreciated.
Re: Help using excel function in PHP
Let me assure you most emphatically that PHP cannot use Excel functions! It might have some functions with the same names, which may or may not do the same things, but they are NOT Excel functions! If it's not in the PHP manual and you haven't defined it, it won't work in PHP. Period.
Re: Help using excel function in PHP
Fair enough. Thank you for responding.