Skip to content

Instantly share code, notes, and snippets.

@gavinblair
Created June 7, 2010 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gavinblair/428909 to your computer and use it in GitHub Desktop.
Save gavinblair/428909 to your computer and use it in GitHub Desktop.
HTML or array?
<select name=”gender”>
<option value=”1”>Male</option>
<option value=”2”>Female</option>
</select>
<select name="gender">
<?php
$options = array(1 => "Male", 2 => "Female" );
foreach($options as $oid => $option){
echo "<option value='$oid'>$option</option>";
}
?>
</select>
@gavinblair
Copy link
Author

@zoster says she would usually use an array if a select had more than three or four options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment