this is showing result like this 70.479
and i want result like that 70.500
how can i do this please help me to fix this issue thanks
<?php //Starting of php
if(isset($_POST['submit']))//if the submit button has pressed
{
$first = $_POST['first']; //Getting Value of first integer from add.html
$sec = $_POST['sec']; //Getting Value of Second integer from add.html
$res = $first * $sec *75 /365 /30; //Adding the two values and placing the added result to 'res' variable
echo 'Added Result:';
echo "<br>Rounded value of the number = ".round($res,3);
}
//Ending of php
?>
Try this,
<?php
echo number_format((round(70.479, 1)),3);
?>
this is what you want in result
Please try with PHP round function.
<?php
echo number_format(round(70.479, 1), 3); // 70.500
?>
http://php.net/manual/en/function.round.php
<?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.