Many times we need to format a number with two decimal points, PHP provides many solutions for rounding a number with decimal values. This tutorial list some functions which can be used to round a number with decimal values upto 2 decimal points.
1. round() : round() function used to round a floating point number to an integer or to fixed number of decimal points.
Note : Second parameter of round function defines the number of decimal points.
2. number_format() : Using number_format() function also we can format a number with two decimal points. number_format() takes two parameters, first is number to format and second is to define the number of decimal points.
3. sprintf() : sprintf() function can also be used to format the number. The sprintf() function takes two parameters, first parameter define the rule for formatting the number and the second parameter is the number to format.