V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ahkxhyl
V2EX  ›  PHP

三组数组 key( name , date)合并,其他 key 求和 求指导

  •  
  •   ahkxhyl · 2017-07-13 21:11:45 +08:00 · 1644 次点击
    这是一个创建于 2480 天前的主题,其中的信息可能已经有所发展或是发生改变。
    $arr = [

    [
    'total'=> 2,
    'name'=> '购物',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    [
    'total'=> 3,
    'name'=> '购物',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    ];

    $arr1 = [

    [
    'total'=> 2,
    'name'=> '汽车',
    'date'=> '2017-06-21',
    'count'=> 1
    ],
    [
    'total'=> 3,
    'name'=> '自行车',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    ];

    $arr2 = [

    [
    'total'=> 2,
    'name'=> '图片',
    'date'=> '2017-06-21',
    'count'=> 1
    ],
    [
    'total'=> 3,
    'name'=> '自行车',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    ];

    主要判断 name && date 的值是否相同 相同则合并同时对 total 和 count 求和,不同加入新数组,最后再组成一个 new array

    求指导 怎么写!!
    第 1 条附言  ·  2017-07-14 09:25:17 +08:00
    $arr = [

    [
    'total'=> 2,
    'name'=> '购物',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    [
    'total'=> 3,
    'name'=> '购物 kuang',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    ];
    1 条回复    2017-07-14 09:26:04 +08:00
    ahkxhyl
        1
    ahkxhyl  
    OP
       2017-07-14 09:26:04 +08:00
    怎么请求删贴的 我自己解决
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   906 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:01 · PVG 04:01 · LAX 13:01 · JFK 16:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.