Skip to content

Instantly share code, notes, and snippets.

@weihanchen
Created July 17, 2018 13:36
Show Gist options
  • Save weihanchen/d98701736d0c801d9e5f74c3f986ac78 to your computer and use it in GitHub Desktop.
Save weihanchen/d98701736d0c801d9e5f74c3f986ac78 to your computer and use it in GitHub Desktop.
php loop
<?php
$options = array(
1 => 'Opt1',
2 => 'Opt2',
3 => 'Opt3',
);
?>
<select name="up_opt">
<?php foreach ($options as $value => $label): ?>
<option value="<?php echo $value; ?>" <?php if ($_GET['up_opt'] == 1) { echo ' selected="selected"'; } ?>><?php echo $label; ?></option>
<?php endforeach ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment