$allPackGoods = array(
['id'=>1,'stock'=>14,'num'=>6],
['id' =>2,'stock'=>20,'num'=>6],
['id'=>3,'stock'=>20,'num'=> ;6],
['id'=>4,'stock'=>18,'num'=>6],
['id'=>5 ,'stock'=>54,'num'=>6]
);
Generate an array according to the number of pieces until the inventory is cleared
Final result Similar to
[[{"id":1,"stock":8,"num":6,"use":6},{"id":2,"stock":14,"num ":6,"use":6},{"id":3,"stock":14,"num":6,"use":6}],[{"id":1,"stock": 2,"num":6,"use":6},{"id":2,"stock":2,"num":6,"use":6},{"id":4,"stock ":12,"num":6,"use":6}]]
But the combination cannot have the same id. How should the code be implemented? Waiting online, asking God for help
To add: This is similar to generating combinations. Each combination can have multiple products. The number of products can be defined, for example, 1-3 2-3