What is the purpose of using foreach loops in PHP for dropdown menus?

When creating dropdown menus in PHP, using foreach loops can simplify the process of generating the options for the menu. By iterating over an array of values, you can dynamically populate the dropdown menu with the options without having to manually write out each option. This makes the code more efficient and easier to maintain.

<select name="dropdown">
    <?php
    $options = array("Option 1", "Option 2", "Option 3");

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