[Solved] Best way to round down in PHP


You can use floor to round down, and the modulo (%) operator to determine how many bottles are left.

$bottles = 100;
$bottles_per_case = 12;

print "There are " . floor($bottles / $bottles_per_case) . " cases...";
print "With " . ($bottles % $bottles_per_case) . " bottles left over";

solved Best way to round down in PHP