php round up
snippet in php

php round up

user2823

//round up to nearest integer
echo(ceil(0.60) . "<br>");
//result 1

2 decimal round using php

user947

// using round() function we can roundoff float values in php
$value = 58.24365;
round($value, 2);
//result 58.24

round up built in function php

user1345

echo ceil(0.5); //Prints 1

round to 2 decimal places php

user3309

round(520.34345, 2);   // 520.34

php round up

user9260


<?php
echo 'Rounding modes with 9.5' . PHP_EOL;
var_dump(round(9.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(9.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_ODD));

echo 'Rounding modes with 8.5' . PHP_EOL;
var_dump(round(8.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(8.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_ODD));
?>

php round to whole number

user7233

$int = 8.998988776636;
round($int) //Will always be 9

$int = 8.344473773737377474;
round($int) //will always be 8