Zend - The PHP Company




Forms

Add Code


Generate array of radio-buttons  

Type: code fragment
Added by: ADMIN
Entered: 12/01/2000
Last modified: 08/12/1999
Rating: **** (4 votes)
Views: 9659
This code produces a set of radio-buttons with given name, with values and texts taken from the array


<?php
  
Function array2radio($arr,$name,$sel "") {
    while ( list( 
$key$val ) = each($arr)) {
        if(
$sel && $key == $sel) {
           
$select_v=" checked";
        } else { 
           
$select_v=""
            }
        echo 
"<input type=radio name="$name" value="$key$select_v$valn";
    }
  }

?>


Usage Example




Rate This Script





Search



This Category All Categories