PHP format number

19.Jul.2010

In order to use PHP to format number output, you should call for a number_format() PHP function using following params: float $number, int $decimals, string $decimalPoint, string $thousandsSeparator.

Use this snippet in order to format number from example:

1
2
3
4
5
$number = 3221.22346;
 
echo number_format($number, 2, ',', ' ');
// PHP format number will output:
// 3 221,22