Thursday, December 4, 2008

Round function

A simple post to show how to use round function in PHP.

Lets take a variable holding a number with decimals:
$number = 21.25116;

Now want to round this number to 3 decimal.
So:
$number = round($number,3);
echo $number;
The result will be something like: 21.251

If $number = 21.2569
then result will be: 21.257

If $number = 21.259652;
Then result will be: 21.26

ANL

No comments: