1// round down
2echo floor(1.5); // prints 1
3
4// round up
5echo ceil(1.5); // prints 2
1
2<?php
3echo 'Rounding modes with 9.5' . PHP_EOL;
4var_dump(round(9.5, 0, PHP_ROUND_HALF_UP));
5var_dump(round(9.5, 0, PHP_ROUND_HALF_DOWN));
6var_dump(round(9.5, 0, PHP_ROUND_HALF_EVEN));
7var_dump(round(9.5, 0, PHP_ROUND_HALF_ODD));
8
9echo 'Rounding modes with 8.5' . PHP_EOL;
10var_dump(round(8.5, 0, PHP_ROUND_HALF_UP));
11var_dump(round(8.5, 0, PHP_ROUND_HALF_DOWN));
12var_dump(round(8.5, 0, PHP_ROUND_HALF_EVEN));
13var_dump(round(8.5, 0, PHP_ROUND_HALF_ODD));
14?>
15
16