Jump to content

calculate inches


brem13
Go to solution Solved by teamatomic,

Recommended Posts

trying to figure out how to calculate inches in php, or if that cant be done, how can i change my select statement to display inches in the drop down, but put the centemeter equivalent in the database, the calculation im talking about is something like > 4'6" & < 6'11'

$array_height1 = array('Any', "4'1"", "4'2"", "4'3"", "4'4" etc);
echo '<select name="height1">';
				foreach($array_height1 as $aheight1)
				{
					$selected = (($aheight1 == $height1) ? ' selected="selected"' : '');
					echo '<option value="'.$aheight1.'"'.$selected.'>'.$aheight1.'</option>';
				}//end for

would there be a way to do a  >4'6" & < 6'11" sort of thing tho

Link to comment
Share on other sites

  • Solution

Why dont you just convert it to inches? then you can compare and when you want to display just divide by 12 and use the modulus.

 

$num=145;

$ft=floor($num/12);

$inch=$num%12;

echo "$ft'$inch\"";//12'1"

 

 

HTH

Teamatomic

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.