How to combine two arrays without duplicates in PHP?

How can I merge two arrays while preserving their original keys and avoiding duplicates in PHP?

I have two arrays:

$array1 = array( 
  '56' => '56',
  '57' => '57',
  '58' => '58',
  '59' => '59',
  '60' => '60',
);

$array2 = array( 
  '58' => '58',
  '59' => '59',
  '60' => '60',
  '61' => '61',
  '62' => '62',
);

I would like to merge these two arrays into a single array, while preserving their original keys, and avoiding duplicates. The desired output is:

$output = array( 
  '56' => '56',
  '57' => '57',
  '58' => '58',
  '59'=> '59',
  '60' => '60',
  '61' => '61',
  '62' => '62'
);

I have tried using array_merge but it changes the original keys. I also tried using array_combine, but it does not seem to be working.

In short, you can use the + operator to combine two arrays. If the same key exists in both arrays, the value from the first array will be preserved, and duplicates will be removed.

$output = $array1 + $array2;

Note: This will not work for arrays without keys.
For example:

$array1 = array('56', '57', '58', '59', '60');
$array2 = array('58', '59', '60', '61', '62');

You can use the array_merge function to combine two arrays and array_unique to remove the duplicates.

$output = array_unique(array_merge($array1, $array2));