round
Description
float round ( float val [, int precision])Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default).
Caution |
When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even. |
Note: PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings.
Note: The precision parameter is only available in PHP 4.
See also ceil(), floor() and number_format().