PHP - round example

The round() function rounds a float
$float = 5233.65;

echo round($float, 2) . PHP_EOL;  // 5233.65
echo round($float, 1) . PHP_EOL;  // 5233.7
echo round($float, 0) . PHP_EOL;  // 5234
echo round($float, -1) . PHP_EOL; // 5230
echo round($float, -2) . PHP_EOL; // 5200
echo round($float, -3) . PHP_EOL; // 5000
echo round($float, -4) . PHP_EOL; // 10000

Round with modes

echo round(4.5, 0, PHP_ROUND_HALF_UP) . PHP_EOL;   // 5
echo round(4.5, 0, PHP_ROUND_HALF_DOWN) . PHP_EOL; // 4
echo round(4.5, 0, PHP_ROUND_HALF_EVEN) . PHP_EOL; // 4
echo round(4.5, 0, PHP_ROUND_HALF_ODD) . PHP_EOL;  // 5

echo round(5.5, 0, PHP_ROUND_HALF_UP) . PHP_EOL;   // 6
echo round(5.5, 0, PHP_ROUND_HALF_DOWN) . PHP_EOL; // 5
echo round(5.5, 0, PHP_ROUND_HALF_EVEN) . PHP_EOL; // 6
echo round(5.5, 0, PHP_ROUND_HALF_ODD) . PHP_EOL;  // 5