PHP Radio Button Display Function

Another simple one that can potentially save a ton of time. This tiny function is especially useful when combined with a for or while loop that cycles through an array of potentially changing options.

function radio($name, $value, $displayText) {
     echo "<input type='radio' name='$name'
          value='$value' />$displayText<br>\n";
}

The code produced by the above with “xxx” passed as $name and “Option 1” passed as $display looks like this:

<input type="radio" name="xxx"> Option 1<br>

The output itself looks like this:  Option 1

You can augment this code with classes, labels, additional HTML, etc.