I want to add the array that is an input. so it would add like this
resistor[1] + resistor[2] + ... and so on. But it won't add all of them for some reason.

if I have 2 inputs of 1000 it only shows 1000 instead of 2000.
PHP Code:
$r $resistors[1] + $resistors[2] + $resistors[3] + $resistors[4]
 + 
$resistors[5] + $resistors[6] + $resistors[7] + $resistors[8]; 
how do I get it so if there was only 2 input it would add then instead of adding all of them all the time. I tried the for loop but I don't think I did it right.