What is the purpose of using array_merge_recursive and array_merge in PHP when combining arrays?

When combining arrays in PHP, the array_merge function is useful for merging arrays with numeric keys, while array_merge_recursive is used for merging arrays with string keys. If you need to merge arrays with both numeric and string keys, you can use array_merge_recursive to recursively merge the arrays.

// Using array_merge_recursive to combine arrays with both string and numeric keys
$array1 = array('a' => 'apple', 'b' => 'banana');
$array2 = array('b' => 'blueberry', 'c' => 'cherry');

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

print_r($result);