What are the potential pitfalls of using array_merge to combine multidimensional arrays in PHP?

When using array_merge to combine multidimensional arrays in PHP, the function will only merge the values of the arrays and not the keys. This can lead to unexpected results if the arrays have the same keys. To avoid this issue, you can use the array_merge_recursive function, which will recursively merge the arrays and preserve the keys.

$array1 = array(
    'fruit' => array('apple'),
    'vegetable' => array('carrot')
);

$array2 = array(
    'fruit' => array('banana'),
    'vegetable' => array('lettuce')
);

$mergedArray = array_merge_recursive($array1, $array2);

print_r($mergedArray);