Page 1 of 1

limiting a number to 2 decimal places

Posted: Fri Jul 29, 2005 5:09 pm
by psychotomus
how can I limited a number to 2 decimal places like

2.34

or have 2.346 be 2.35

Posted: Fri Jul 29, 2005 5:13 pm
by John Cartwright

Posted: Fri Jul 29, 2005 10:52 pm
by s.dot
take a look at the round() function

Code: Select all

$number = 5.73458565;
$twodecimals = round($number,2);
for more functions dealing with this see ceil() floor() number_format()