How can PHP be used to dynamically generate options for a dropdown menu?

To dynamically generate options for a dropdown menu using PHP, you can create an array of options and loop through it to generate the HTML code for each option. This allows you to easily add or remove options without having to manually update the HTML code each time.

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

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