合并两个共享一个公共索引的数组中的数组 - php

I have two arrays that have common indexes (church and office). I need to "merge" the total of the first array into the second array to get the desired output (seen below the double line). I'm not sure how to do this with array_merge(). Any help would be greatly appreciated!

Array
(
    [church] => Array
        (
            [total] => 77
        )

    [office] => Array
        (
            [total] => 202
        )

)

Array
(
    [church] => Array
        (

            [name] => Array
                (
                    [0] => Bill
                    [1] => Sally
                )

            [addr] => Array
                (
                    [0] => Address Same as Billing
                    [1] => Address Same as Billing
                )

            [message] => Array
                (
                    [0] => 
                    [1] => 
                )

            [amount] => Array
                (
                    [0] => 25
                    [1] => 50
                )

        )

    [office] => Array
        (

            [name] => Array
                (
                    [0] => Marta
                    [1] => Ruth
                )

            [addr] => Array
                (
                    [0] => Address Same as Billing
                    [1] => Address Same as Billing
                )

            [message] => Array
                (
                    [0] => 
                    [1] => 
                )

            [amount] => Array
                (
                    [0] => 100
                    [1] => 100
                )

        )

)

====================================================

Array
(
    [church] => Array
        (
        [total] => 77

            [name] => Array
                (
                    [0] => Bill
                    [1] => Sally
                )

            [addr] => Array
                (
                    [0] => Address Same as Billing
                    [1] => Address Same as Billing
                )

            [message] => Array
                (
                    [0] => 
                    [1] => 
                )

            [amount] => Array
                (
                    [0] => 25
                    [1] => 50
                )

        )

    [office] => Array
        (
        [total] => 202

            [name] => Array
                (
                    [0] => Marta
                    [1] => Ruth
                )

            [addr] => Array
                (
                    [0] => Address Same as Billing
                    [1] => Address Same as Billing
                )

            [message] => Array
                (
                    [0] => 
                    [1] => 
                )

            [amount] => Array
                (
                    [0] => 100
                    [1] => 100
                )

        )

)

Try something like this:

$a = array('church' => array('total' => 5), 'office' => array('total' => 10));
$b = array('church' => array('name' => 'church'), 'office' => array('name' => 'office'));

foreach ( $b as $key => $value ) {
  $b[$key] = array_merge($a[$key], $b[$key]);
}