Forum und email

round

(PHP 4, PHP 5)

round — Rondt een float af

Beschrijving

float round ( float $val [, int $precision ] )

Geeft de afgeronde waarde van val met de gespecificeerde precision (aantal cijfers achter de komma). precision kan ook negatief zijn of 0 (standaard).

Caution

PHP behandeld strings als "12,300.2" standaard niet correct. Zie converteren van strings.

echo round(3.4);         // 3
echo round(3.5);         // 4
echo round(3.6);         // 4
echo round(3.6, 0);      // 4
echo round(1.95583, 2);  // 1.96
echo round(1241757, -3); // 1242000

Note: De precision parameter is alleen beschikbaar in PHP 4.

Zie ook: ceil() en floor().