Signatur
number_format(float $num, int $decimals = 0, string $decimal_separator = ".", string $thousands_separator = ","): string
Beschreibung
Standard ist englische Formatierung. Deutsch: number_format($n, 2, ',', '.').
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $num Pflicht | float | — | Zahl. |
| $decimals | int | 0 | Dezimalstellen. |
| $decimal_separator | string | "." | Dezimal-Zeichen. |
| $thousands_separator | string | "," | Tausender-Zeichen. |
Rückgabewert
Typ
string
Beschreibung
Formatierte Zahl.
Beispiele
Deutsch formatiert
<?php
echo number_format(1234567.89, 2, ',', '.'); // 1.234.567,89
Ohne Dezimalstellen
<?php
echo number_format(1234567); // 1,234,567 (englisch)