Reputation: 13150
Actually, "rounding" may not be the best name to describe what I'm looking to do.
I want to round only floats that have zeros after the decimal point: ".00"
I don't want to display any decimal numbers if there are zeros after the decimal point. Normally I'd just look for ".00" in the variable, and if it has what I'm looking for I just strip it out. However, there are a few instances that the decimal might be longer than 2 places. like: 45.000 or 56.0000
I didn't want to mess with any regex on this if there was a php function that stripped out the extra zeros, if they exist.
Upvotes: 1
Views: 340
Reputation:
Use round($f,2);
http://php.net/manual/en/function.round.php
For that genius who downvoted: http://codepad.org/2bBA5UpL
Upvotes: 0