Ah, I see it. The value that's 10 years old needs to be divided by the rate 10 times. Or (1+rate)^10
If you do this
$npv = ($values[$year - $i] + $npv) / (1 + $rate);
then it should work, since you

In your code is $rate 8.15 or .0815? It needs to be .0815; if it isn't use $rate/100.
Also, you should not be dividing by (1+$rate) you should multiply by (1-$rate).
If I understand the question correctly, that should be all you need to get it working right.

Ah, I see it. The value that's 10 years old needs to be divided by the rate 10 times. Or (1+rate)^10
If you do this
$npv = ($values[$year - $i] + $npv) / (1 + $rate);
then it should work, since you are already running backward through the array.

By the way, I would do the for loop like this, but it either way is the same.
for ($i=$year;$i>=0;$i-=1) {
$npv = ($values[$i] + $npv) / (1 + $rate);
}

Actually, if array[0] is the capital outlay, shouldn't you run through starting at 0 and going to $year?

Er... That last line might not make sense. I don't know NPV that well, I'm just good at figuring formulas out. Doing it the way I suggested matched Excel perfectly.

Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…

Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions.
Consider email address RFCs:
Look at HTML5 form input element (with type=email) regex pattern:
T…