First, I generate an array of 3 positions with random numbers, and then try to subtract the three values from the array. The problem is that if the first subtraction gives me a negative number, the following value does not subtract it well.

For example:

$ given =[6,4,4]

The subtraction would be: 6-4-4 = -2

But when I run it, subtraction gives me: 6

My code:

```
for ($ i = 0; $ i <= 2; $ i ++) {
$ given[]= rand (1.6);
given echo $[$i]& # 39; | & # 39 ;;
}
$ subtraction = 0;
for ($ i = 0; $ i<=2;$i++){
if($dado[$i]>= 0) {
$ subtraction = $ given[$i]- $ subtraction;
} elseif ($ given[$i]<0) {
$ subtraction = $ given[$i]+ $ subtraction;
}
}
```