Format numbers and prices

number_format() adds separators. round(), floor() and ceil() change the value itself.

PHP · Format numbers and pricesBeginner
$n = 1234567.891;

echo number_format($n);                 // 1,234,568
echo number_format($n, 2);              // 1,234,567.89
echo number_format($n, 2, ',', '.');    // 1.234.567,89

echo round(3.14159, 2);                 // 3.14
echo floor(4.9);                        // 4
echo ceil(4.1);                         // 5
echo intdiv(17, 5), ' ', 17 % 5;        // 3 2
number_formatroundmoney