Signatur
round(int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float
Beschreibung
Modi: PHP_ROUND_HALF_UP (Standard, kaufmännisch), _HALF_DOWN, _HALF_EVEN (Banker's Rounding), _HALF_ODD.
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $num Pflicht | int|float | — | Zahl. |
| $precision | int | 0 | Dezimalstellen. Negativ: auf 10er/100er. |
| $mode | int | PHP_ROUND_HALF_UP | Rundungsmodus. |
Rückgabewert
Typ
float
Beschreibung
Gerundete Zahl.
Beispiele
Cents
<?php
echo round(19.995, 2); // 20.00
Auf 10er
<?php
echo round(1234, -1); // 1230