What is the purpose of reassociating an associative array in PHP?

When reassociating an associative array in PHP, the purpose is to change the keys of the array while keeping the values intact. This can be useful when you need to reorganize the data in the array or when you want to access the values using different keys.

// Original associative array
$originalArray = array(
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3'
);

// Reassociating the array with new keys
$reassociatedArray = array(
    'newKey1' => $originalArray['key1'],
    'newKey2' => $originalArray['key2'],
    'newKey3' => $originalArray['key3']
);

print_r($reassociatedArray);