Saturday 30 July 2016

Convert Centimeters(cm) to Feets and Inches in PHP

Very useful php function to convert centimeter to display as Feets and inches. This function is used to calculate height of celebrities.

function cm2feet($cm) {
            $inches = $cm/2.54;
            $feet = intval($inches/12);
            $inches = $inches%12;
            return sprintf('%d \' %d "', $feet, $inches);

}

No comments:

Post a Comment