'How to convert the int value to inch in PHP [closed]

I just want to know how to convert inch based on the integer inputted in the field.

For Example:

$int = $_POST['int']; //value 1

//computation here...

$inch = //formula

//echoing the inch
echo $inch;
php


Solution 1:[1]

If you want convert from centimeter can you use this source

function cm2inches($cm)
{
     $inches = $cm/2.54;
     $inches = $inches%12;
     return sprintf('%d ins', $inches);
}
echo cm2inches(162);

You will have result

3 ins

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Quynh Nguyen