PHP Language
Is it difficult to write a function to subtraction value from each [Amount] values in array ?, all that until subtraction value is appeased ?.
Example what i need (before subtraction):
[MainStockAddedArr] => Array
(
[0] => Array
(
[Amount] => 10
[Price] => 19.44
)
[1] => Array
(
[Amount] => 15
[Price] => 15.55
)
[2] => Array
(
[Amount] => 20
[Price] => 11.55
)
[3] => Array
(
[Amount] => 30
[Price] => 11.10
)
)
Value to subtraction is for example 30 pieces. So i would need to have results in array look like this:
[MainStockAddedArr] => Array
(
[0] => Array
(
[Amount] => 0
[Price] => 19.44
)
[1] => Array
(
[Amount] => 0
[Price] => 15.55
)
[2] => Array
(
[Amount] => 15
[Price] => 11.55
)
[3] => Array
(
[Amount] => 30
[Price] => 11.10
)
)
In above example, two values are changed to 0 so that gives 25 pieces already been taken, on third value only 5 has been taken, that gives 30 pieces so no more is needed. This is just example, subtraction value will be dynamic, from a loop which is above this one.
In situation where subtraction value would be greater than in whole array (sum [Amounts]), else is needed.