Skip to content

Instantly share code, notes, and snippets.

@RandomArray
Created July 20, 2016 06:36
Show Gist options
  • Save RandomArray/ecadf7a8c42195a5f3c37a7585e0cb76 to your computer and use it in GitHub Desktop.
Save RandomArray/ecadf7a8c42195a5f3c37a7585e0cb76 to your computer and use it in GitHub Desktop.
Generates HTML Select box for person's height in inches.
<?php
function personHeightOptions(){
$itotal = 95; $r = '';
for($foot=7;$foot>=3;$foot--){
for($inches=11;$inches>=0;$inches--){
if($inches==0){
$r .= "<option value='$itotal'> $foot' 0\" </option>";
}else{
$r .= "<option value='$itotal'> $foot' $inches\" </option>";
}
$itotal--;
}
}
return $r;
}
?>
<select name="person_height" id="person_height">
<option disabled selected>Height</option>
<?php echo personHeightOptions(); ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment