I will try to explain the problem that I have with this code.
This script works well to up to three persons ($numRows = 3).
$z=0;
$i=0;
$x=0;
do {
$total[] = (
${'contaH'.$z}[$i+0]*$final[$x+0]+
${'contaH'.$z}[$i+1]*$final[$x+1]+
${'contaH'.$z}[$i+2]*$final[$x+2]
);
$z++;
} while ($z<$numRows); //3
But if I have only four persons ($numRows = 4), I need something like this:
$z=0;
$i=0;
$x=0;
do {
$total[] = (
${'contaH'.$z}[$i+0]*$final[$x+0]+
${'contaH'.$z}[$i+1]*$final[$x+1]+
${'contaH'.$z}[$i+2]*$final[$x+2]+
${'contaH'.$z}[$i+3]*$final[$x+3]
// if they are 5 persons ($numRows=5), here, should exists another row
);
$z++;
} while ($z<$numRows); //4
So the problem is to automate these changes in relation of $numRows.
Here is a demo of matrix algebra:

The only thing that I want is put my code dynamically in a function of number of persons.
A | B | C | D
Person1
Person2
Person3
Person4
...
What can be different in my case is just the number of persons.
More information here.
$contaH0,$contaH1etc? Why aren't you using arrays instead?$total[] = ()should have a variable number of sums.$total[] = (1), $total[] = (1+1), $total[] = (1+1+1), $total[] = (1+1+1+1), $total[] = (1+1+1+1+1). The number of sums change in function of$numRows. i can't be more clear :S