I am trying to build a conversion calculator fractions to decimals.
I have this an it works except it always puts in a leading zero. if I want to add a number before the anwer like 2 3/4 the result will be 20.75.
<?php
/// Get Numbers and Set Variables ///
$numerator1 = $_POST['numerator1'];
$denominator1 = $_POST['denominator1'];
$numerator2 = $_POST['numerator2'];
$denominator2 = $_POST['denominator2'];
$number3 = $_POST['number3'];
$number4 = $_POST['number4'];
/// Math ///
$mult1 = $numerator1 / $denominator1 ;
$mult2 = $numerator2 / $denominator2 ;
/// Convert to 3 places after decimal ///
$final1 = number_format($mult1,3);
$final2 = number_format($mult2,3);
//Print Final Numbers
print "<p>$number3$final1</p>";
print "<p>$number4$final2</p>";
?>
Is there away to remove the 0 from the 0.75 so it will output 2.75?
Thanks,
Josh