function createOptionFromArray($myArray,$selected) { if(!is_array($myArray)) { return false; } $returned = $select = ''; foreach($myArray as $key => $value) { if($selected == $key) { $select = ' selected'; } $returned .= "<option value=\"$key\"$select>$value</option>"; $select = ''; } return $returned; } $option = array(0 => 'Rent', 1 => 'Own'); $selected = (isset($_POST['rent_own']) && intval($_POST['rent_own']) < 2) ? $_POST['rent_own'] : ''; print "<select name=\"rent_own\">\n"; print createOptionFromArray($option,$selected); print "</select>\n";
I am trying to get my form to hold the value of the selext box which it does. But the value I get back is "1" or "0".
I need to have the value be "Rent" or "Own". How can I do this?
$rent_own = $_POST['rent_own']