php class not working
Posted: Thu Oct 19, 2006 3:51 pm
I am trying to use the following class to produce the npv (Net Pressent Value) of some numbers. I am using this for a custom app for our accounting office.
what am I doing wrong, or is there another way to calculate NPV?
Code: Select all
class npv {
function calcNPV($rate, $values) {
for ($i=0;$i<=count($values);$i+=1) {
$npv = $values[count($values) - $i] + $npv / (1 + $rate);
}
return $npv;
}
}
// using the function
$npv = new npv();
print $npv->calcNPV(0.09, array(0,30,40,50,60,70));