How can PHP code readability be improved when dealing with form select options?

When dealing with form select options in PHP, code readability can be improved by using an associative array to define the options. This makes it easier to understand the relationship between the option value and display text. Additionally, using foreach loops to iterate over the array can simplify the code and make it more maintainable.

// Define an associative array for select options
$options = [
    '1' => 'Option 1',
    '2' => 'Option 2',
    '3' => 'Option 3',
];

// Output select options using a foreach loop
echo '<select name="select">';
foreach ($options as $value => $text) {
    echo '<option value="' . $value . '">' . $text . '</option>';
}
echo '</select>';