Merging of PHP two-dimensional arrays

merge arrays according to field seller_id
Array $result is as follows

Array
(
    [0] => Array
        (
            [seller_id] => 17140
            [bp_counts] => 1
        )

    [1] => Array
        (
            [seller_id] => 17140
            [dr_counts] => 9
        )
    [3] => Array
        (
            [seller_id] => 17140
            [dc_counts] => 10
        )
)

the desired array is

Array
(
    [0] => Array
        (
            [seller_id] => 17140
            [bp_counts] => 1
            [dr_counts] => 9
            [dc_counts] => 10
        )

)

ask the great god to help solve it, thank you.

Mar.22,2021

function field_merge($data, $field = 'seller_id') {
    $result = [];
    foreach ($data as $item) {
        if (!isset($result[$item[$field]])) {
            $result[$item[$field]] = [];
        }
        $result[$item[$field]] = array_merge($result[$item[$field]] ?: [], $item);
    }
    return array_values($result);
}

`
function field_merge ($data) {

foreach ($data as $v) {
    foreach ($v as $m => $n) {
        if(!isset($result[$m])){
            $result[$m] = $n;
        }
    }
}
$return[] = $result;
return $return;

}
`


$res = [];
foreach ($arr as $key = > $value) {

$res += $value;

}

Menu