PHP Radio Button Display Function

If you have a ton of radio buttons to display, this is a great time-saver. This is especially useful when combined with a for or while loop that cycles through an array of options.

function radio($name, $value, $display) {
     print '<input type="radio" name="' . $name . 
           '" value="' . $value . '" />' . " $display" . "<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.