How can PHP be used to dynamically generate radio buttons and associated text?

To dynamically generate radio buttons and associated text in PHP, you can use a loop to iterate through an array of options and generate the necessary HTML code for each option. This allows you to easily add or remove options without having to manually update the code.

$options = array("Option 1", "Option 2", "Option 3");

foreach ($options as $option) {
    echo '<input type="radio" name="option" value="' . $option . '">';
    echo '<label>' . $option . '</label><br>';
}