<?php
$base = array('citrus' => array("orange") , 'berries' => array("blackberry", "raspberry"), 'others' => 'banana' );
$replacements = array('citrus' => 'pineapple', 'berries' => array('blueberry'), 'others' => array('litchis'));
$replacements2 = array('citrus' => array('pineapple'), 'berries' => array('blueberry'), 'others' => 'litchis');
$basket = array_replace_recursive($base, $replacements, $replacements2);
print_r($basket);
?>
     
    The above example will output:
Array
(
    [citrus] => Array
        (
            [0] => pineapple
        )
    [berries] => Array
        (
            [0] => blueberry
            [1] => raspberry
        )
    [others] => litchis
)