Skip to main content

Posts

Showing posts from 2024

Height in Feet and Cms using PHP

The following code can be used to generate a Select field as displayed in the image. It is done in core php. <select name="height" required> <option value="">Select</option> <?php for($inches=48;$inches<=78;$inches++) //Change the range in inches as required { $cm=ceil($inches*2.54); $feet=(($inches-($inches % 12))/12)."&rsquo; ".($inches % 12)."&rdquo;"; ?> <option value="<?php echo $cm; ?>"><?php echo $feet.' ('.$cm.' cms)'; ?></option> <?php } ?> </select> Keywords: html form select options convert height length inch cm cms to feet