How can array_map() be used to combine two arrays in PHP?

To combine two arrays in PHP using array_map(), we can create a custom function that merges the elements of the two arrays together. The array_map() function can then be used to apply this custom function to each pair of elements from the two arrays, resulting in a new array that combines the elements from both arrays.

$array1 = [1, 2, 3];
$array2 = ['a', 'b', 'c'];

$combinedArray = array_map(function($a, $b) {
    return $a . $b;
}, $array1, $array2);

print_r($combinedArray);