ahkxhyl
V2EX  ›  PHP

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

  •  
  •   ahkxhyl · Jul 13, 2017 · 2273 views
    This topic created in 3252 days ago, the information mentioned may be changed or developed.
    $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

    求指导 怎么写!!
    Supplement 1  ·  Jul 14, 2017
    $arr = [

    [
    'total'=> 2,
    'name'=> '购物',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    [
    'total'=> 3,
    'name'=> '购物 kuang',
    'date'=> '2017-06-20',
    'count'=> 1
    ],
    ];
    1 replies    2017-07-14 09:26:04 +08:00
    ahkxhyl
        1
    ahkxhyl  
    OP
       Jul 14, 2017
    怎么请求删贴的 我自己解决
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1075 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 22:43 · PVG 06:43 · LAX 15:43 · JFK 18:43
    ♥ Do have faith in what you're doing.