What are the benefits of using associative arrays for dropdown menu options in PHP?

When creating dropdown menu options in PHP, using associative arrays can make the code more organized and easier to manage. By storing the options as key-value pairs in an array, it allows for easy access to the options and their corresponding values. This can simplify the process of populating dropdown menus with dynamic data and can make it easier to update the options in the future.

// Example of using an associative array for dropdown menu options
$options = [
    '1' => 'Option 1',
    '2' => 'Option 2',
    '3' => 'Option 3'
];

echo '<select>';
foreach ($options as $key => $value) {
    echo '<option value="' . $key . '">' . $value . '</option>';
}
echo '</select>';