php 多个商品生成二维数组 把库存清空掉
Linda Hamilton
Linda Hamilton 2020-09-10 11:32:25
0
1
879

$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]

);

按照件数去生成数组直到把库存都清空掉

最终结果类似

[[{"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}]]

但是组合里面不能有相同的id,代码应该如何实现?在线等,求大神解救

Linda Hamilton
Linda Hamilton

全部回复 (1)
Cklein

补充一下:这里类似是生成组合 每个组合下面可以有多个商品 商品数量可以定义例如 1-3个 2-3个

    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责声明 Sitemap
    PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!