What is the significance of using key-value pairs in arrays when accessing values in PHP?

Using key-value pairs in arrays allows for easy and efficient access to specific values within the array. By assigning keys to each value, you can directly reference the desired value using the associated key, rather than having to iterate through the entire array to find it. This improves code readability and performance when accessing specific elements in an array.

// Using key-value pairs in arrays for efficient value access
$array = [
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3'
];

// Accessing a specific value using its key
echo $array['key2']; // Output: value2