I will try to explain the problem associated with this code.
This script works well for up to three people ($ 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 people ($ 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]
);
$z++;
} while ($z<$numRows);
So the problem is automating these changes with respect to $ numRows.
Here is the diagram of matrix algebra:

The only thing I want is the dynamic code of my code as a function of the number of people.
A | B | C | D
Person1
Person2
Person3
Person4
...
In my case, it can be different - it's just the number of people.
More info here .
source
share