毫米到英尺/英寸 [英] millimeters to feet/inches
本文介绍了毫米到英尺/英寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以帮助我创建一个将毫米转换为英尺/英寸的功能.
I was wondering if anyone could help me create a function that will turn millimeters into feet/inches.
示例:5280mm将返回为17ft/3.87inches(或17'3)
Example: 5280mm will be returned as 17ft / 3.87inches (or 17'3")
我知道脚上有304.8毫米,这给了我17.322834645669(使用上面的相同示例),但是我不确定如何将其格式化为更易读的内容.
I know that there's 304.8mm in a foot, which gives me 17.322834645669 (using the same example above) but I'm not sure how to then format it into something more legible.
function getMeasurements($mm) {
return ($mm/304.8);
}
推荐答案
如果有人想做同样的事情,这就是我用来计算毫米到英尺/英寸的方式:
And if anyone is looking to do the same thing, this is what I used to calculate mm to ft/inches:
function getMeasurements($mm) {
$inches = ceil($mm/25.4);
$feet = floor(($inches/12));
$measurement = $feet."'".($inches%12).'"';
return $measurement;
}
哪个返回类似:17'3.
Which returns something like: 17'3".
这篇关于毫米到英尺/英寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文