0
我使用下面的代碼來轉換米到腳。它的作用像一個魅力,但我想在小數點後面添加英寸部分。如何在代碼之前和之後將小數點和英寸添加到小數點?
當前輸出
6.2 feet
希望的輸出
6 feet 2 inches
或
6'2"
下面是代碼:
<?php
$meters=$dis[height];
$inches_per_meter = 39.3700787;
$inches_total = round($meters * $inches_per_meter); /* round to integer */
$feet = $inches_total/12 ; /* assumes division truncates result; if not use floor() */
$inches = $inches_total % 12; /* modulus */
echo "(". round($feet,1) .")";
?>
[你有什麼試過?](http://whathaveyoutried.com) – 2012-08-23 17:17:39