Created
May 19, 2013 19:36
-
-
Save mewm/5608706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Define options | |
$options = new ArrayObject(array( | |
'a', | |
'b', | |
'c', | |
'd', | |
'e', | |
'f' | |
)); | |
?> | |
<select name="hlength"> | |
<?php | |
$chosenValue = (isset($value['hl']) ? $value['hl'] : null); //The value defined here will be the selected one | |
echo '<option value="">Unable to determine</option>'; //Default, and top option | |
//Iterate options | |
foreach ($options->getIterator() as $value) { | |
echo '<option'. (($value == $chosenValue) ? ' selected="selected"' : '') .' value="'. $value .'">'. $value .'</option>'; | |
} | |
?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment