What is the best way to extend an array in PHP without overwriting existing data?

When extending an array in PHP, it is important to ensure that existing data is not overwritten. One way to achieve this is by using the `array_merge` function, which combines two or more arrays without overwriting existing keys. This function creates a new array with the values of the arrays passed as arguments.

// Existing array
$existingArray = ['a' => 1, 'b' => 2];

// Array to add
$newArray = ['c' => 3, 'd' => 4];

// Extend the existing array without overwriting existing data
$extendedArray = array_merge($existingArray, $newArray);

// Output the extended array
print_r($extendedArray);