1$num = 12345.6789;
2echo number_format($num, 2, '.', '') //12345.67
3echo number_format($num, 3, ',', '.') //12.345,678
1
2$number = 1234.56;
3// Notation anglaise (par défaut) ENGLISH
4$english_format_number = number_format($number);
5// 1,235
6
7// Notation française FRENCH
8$nombre_format_francais = number_format($number, 2, ',', ' ');
9// 1 234,56
10
11$number = 1234.5678;
12// Notation anglaise sans séparateur de milliers
13$english_format_number = number_format($number, 2, '.', '');
14// 1234.57
15
16number_format( float $num, int $decimals = 0,
17 ?string $decimal_separator = ".",
18 ?string $thousands_separator = ","
19): string
20
21
22
1<?php
2echo number_format("1000000")."<br>";
3echo number_format("1000000",2)."<br>";
4echo number_format("1000000",2,",",".");
5?>
1// string number_format ($number, $decimals, $decimalpoint, $seperator)
2
3// Enter the number you wish to format using decimals
4// to set the number of decimal places
5// You can replace the '.' with your own string
6// with the decimalpoint parameter.
7// With seperator, you can specify a string to be used
8// to seperate thousands.
9
10$num = 123456.789;
11echo number_format($num); // 123,456
12echo number_format($num, 4); // 123,456.7890
13echo number_format($num, 4, '#'); // 123,456#7890
14echo number_format($num, 5, '#', 'T'); // 123T456#78900
1
2$num = 12345.6789;
3echo number_format($num, 2, '.', '') //12345.67
4echo number_format($num, 3, ',', '.') //12.345,678