php round number half down code example
Example 1: php round down
// round down
echo floor(1.5); // prints 1
// round up
echo ceil(1.5); // prints 2
Example 2: php round nearest half
$x = floor($x * 2) / 2;
// round down
echo floor(1.5); // prints 1
// round up
echo ceil(1.5); // prints 2
$x = floor($x * 2) / 2;