Help with displaying a float value
Moderator: General Moderators
-
DudeBori82
- Forum Commoner
- Posts: 26
- Joined: Thu Nov 18, 2004 10:09 am
- Location: Florida
Help with displaying a float value
How do I limit the amount of decimal places when using 'echo' to display a float value. (It defaults to three I think, but I want it to display only two.) Please share with me your great wisdom and knowledge. 
How bout this
Does this help?
Code: Select all
<?php
echo round(5.045, 2); // echos 5.05
?>not echo but if you
will output 12.44
Code: Select all
<?php
$unitCost = 12.4456;
sprintf("%01.2f",$unitCost);
?>