汇总多维数组的值,其中重复数组中的某些项

I'm drawing a blank here and need some help. I have a multi-dimensional array and i need to combine the data from the same "tenant_id" item so I end up with one array with summed up "item_amounts" and concatenated descriptions for any tenant_id duplicates.

Here is my php array...notice the first 2 elements are from the same tenant_id, which I need to combine into one and add together the "item_amount" to get one final total:

/*
array(4) {
  [0]=>
  array(5) {
    ["tenant_id"]=>    string(5) "11252"
    ["payment_method_id"]=>    string(1) "4"
    ["item_amount"]=>    string(4) "1.00"
    ["description"]=>    string(4) "Rent"
    ["acctg_payment_id"]=>    int(3073)
  }
  [1]=>
  array(5) {
    ["tenant_id"]=>    string(5) "11252"
    ["payment_method_id"]=>    string(1) "4"
    ["item_amount"]=>    string(4) "1.20"
    ["description"]=>    string(12) "Security dep"
    ["acctg_payment_id"]=>    int(3074)
  }
  [2]=>
  array(5) {
    ["tenant_id"]=>    string(5) "11175"
    ["payment_method_id"]=>    string(1) "4"
    ["item_amount"]=>    string(4) "1.10"
    ["description"]=>    string(4) "Rent"
    ["acctg_payment_id"]=>    int(3075)
  }
  [3]=>
  array(5) {
    ["tenant_id"]=>    string(5) "11120"
    ["payment_method_id"]=>    string(1) "4"
    ["item_amount"]=>    string(4) "1.00"
    ["description"]=>    string(1) "r"
    ["acctg_payment_id"]=>    int(3076)
  }
}

*/  

This is the end result I'm hoping for which has a summed up "invoice_amount" and a concatenated description for those "tenant_id" that are the same:

/*
    array(4) {
      [0]=>
      array(5) {
        ["tenant_id"]=>    string(5) "11252"
        ["payment_method_id"]=>    string(1) "4"
        ["item_amount"]=>    string(4) "2.20"
        ["description"]=>    string(4) "Rent,Security dep"
        ["acctg_payment_id"]=>    int(3073)
      }
      [1]=>
      array(5) {
        ["tenant_id"]=>    string(5) "11175"
        ["payment_method_id"]=>    string(1) "4"
        ["item_amount"]=>    string(4) "1.10"
        ["description"]=>    string(4) "Rent"
        ["acctg_payment_id"]=>    int(3075)
      }
      [2]=>
      array(5) {
        ["tenant_id"]=>    string(5) "11120"
        ["payment_method_id"]=>    string(1) "4"
        ["item_amount"]=>    string(4) "1.00"
        ["description"]=>    string(1) "r"
        ["acctg_payment_id"]=>    int(3076)
      }
    }

    */  

Any help on figuring out how to accomplish this will be appreciated.

Thanks.

Yeah, don't do that. You're not only losing information, but the info that you leave in is misleading. eg: you consolidate multiple payments, but leave in one acctg_payment_id. I suggest something like:

[
    '11252' => [ //tenant ID
        'total_paid' => 220,
        'payments' => [
            [ /* payment 3073 */ ],
            [ /* payment 3074 */ ],
        ]
    ],
    ...
]

Which should be output by:

$res = [];
foreach($payments as $payment) {
    $tid = $payment['tenant_id'];
    if( !isset($res[$tid]) ) {
        $res[$tid] = [
            'total_paid' => $payment['item_amount'],
            'payments' => [$payment]
        ];
    } else {
        $res[$tid]['total_paid'] += $payment['item_amount'];
        $res[$tid]['payments'][] = $payment;
    }
}