Generic filters
Exact matches only

Show only 2 decimal places

29th July 2013

Php - Maths

php codehaven

Two ways of doing this…be careful….
Best way ..

This now shows 123.00 (it has added two decimal places as zeros, to make up the number)

Second way …. (not as good, as it rounds up to 2 decimal places)

This will show 23.12 (and can be added to another number)
But…..if the answer was 123.00 it would show 123 (this is a problem, so use above way)

Third way…

This will show 23.12 (but if it goes over 1000 will show a comma therefore not be able to add to another number)

Use both at once to be sure!

Was this code snippet helpful?

Comment on this Code Snippet?