generate an array from an array with conditions
- by Aman
Suppose i have an array
$x = (31,12,13,25,18,10);
I want to reduce this array in such a way that the value of each array element is 32.
so after work my array will become
$newx = (32,32,32,13);
I have to generate this array in such a way the sum of array values is never greater than 32. so to create first value, i will reduce 1 from second index value i.e. 12, so the second value will become 11 and first index value will become 31+1 =32. This process should continue so that each array value becomes equal to 32.