How can the issue of outputting both "de" and "en" in the dropdown menu be resolved in the given PHP code?

The issue of outputting both "de" and "en" in the dropdown menu can be resolved by creating an associative array where the keys are the language codes and the values are the corresponding language names. Then, iterate over this array to generate the dropdown options dynamically.

<?php
$languages = [
    'de' => 'German',
    'en' => 'English'
];

echo '<select name="language">';
foreach ($languages as $code => $name) {
    echo '<option value="' . $code . '">' . $name . '</option>';
}
echo '</select>';
?>