I'm having a problem in PHP, I want to get all possible combinations or distributions to add to some values, for example:
$unities = 3;
$array = [ 1, 2, 3 , 4]
What I want to do is get every possibility to add that unities to the numbers in the array, like a loop that makes:
3 0 0 0
0 3 0 0
0 0 3 0
0 0 0 3
2 1 0 0
2 0 1 0
2 0 0 1
.......
.......
Continue
.......
.......
And add that to the array, so the result must be:
4 2 3 4
1 5 3 4
1 2 6 4
1 2 3 7
3 3 3 4
3 2 4 4
3 2 3 5
.......
.......
Continue
.......
I hope is well explained and you can help me.
Thanks a lot.