What are the recommended PHP functions or methods for copying associative key-value pairs to a new array?

When copying associative key-value pairs to a new array in PHP, you can use functions like `array_merge()`, `array_replace()`, or a simple loop to achieve this. These functions allow you to combine multiple arrays into a new array while preserving the key-value pairs. Using these functions simplifies the process of copying associative data to a new array without losing any information.

// Using array_merge() function
$originalArray = ['key1' => 'value1', 'key2' => 'value2'];
$newArray = array_merge([], $originalArray);

// Using array_replace() function
$originalArray = ['key1' => 'value1', 'key2' => 'value2'];
$newArray = array_replace([], $originalArray);

// Using a loop
$originalArray = ['key1' => 'value1', 'key2' => 'value2'];
$newArray = [];
foreach ($originalArray as $key => $value) {
    $newArray[$key] = $value;
}