Example 1: round up built in function php
echo ceil(0.5);
Example 2: php round up
echo(ceil(0.60) . "<br>");
Example 3: floor ceil php
echo(floor(0.60) . "<br>"); echo(floor(0.40) . "<br>"); echo(floor(5) . "<br>"); echo(floor(5.1) . "<br>"); echo(floor(-5.1) . "<br>"); echo(floor(-5.9)); echo(ceil(0.60) . "<br>"); echo(ceil(0.40) . "<br>"); echo(ceil(5) . "<br>"); echo(ceil(5.1) . "<br>"); echo(ceil(-5.1) . "<br>"); echo(ceil(-5.9));
Example 4: php round up
<?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)); ?>
Comments
Post a Comment