The function you need is called number_format().

Using number_format (9876.54321, 2) would return 9876.54.

Just change the second number (2) to change the number of decimals.

This is great for money figures and cleaning up long strings of numbers after the decimal point.

Leave a Reply