Convert centimeters (cm) into feets and inches using PHP -


i trying convert centimeters feets , inches using php.

this function use calculation.

function getmeasurements($cm) {      $inches = ceil($cm/2.54);     $feet = floor(($inches/12));     $measurement = $feet."' ".($inches%12).'"';      return $measurement; } 

i calling function :

$cm = 185; echo "my height = ".getmeasurements($cm); 

problem after calling can result this-

my height = 6' 73"

look @ inches. incorrect. can tell me whats reason such result.

thank you.

[akshay@localhost tmp]$ cat test.php   <?php  function cm2feet($cm) {      $inches = $cm/2.54;      $feet = intval($inches/12);      $inches = $inches%12;      return sprintf('%d ft %d ins', $feet, $inches); }  echo cm2feet(162)  ?> 

output

[akshay@localhost tmp]$ php test.php 5 ft 3 ins 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -