note 40006 added to function.number-format

From: Date: Wed, 18 Feb 2004 17:29:31 +0000
Subject: note 40006 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-65350@lists.php.net to get a copy of this message
As pointed by another user, number_format *does* round the value but only in certain cases and in certain ways. $value = 123.76; echo number_format($value); // prints 124 echo number_format($value, 1); // prints 123.8 echo number_format($value, 2); // prints 124.76 So what is important is the number of decimal places you specify. If you are dealing with monetary values, such as 50 dollars and 45 cents, then make sure you specify 2 decimal places (and not 0, 1, 3, or more). That way it will show 50.45 instead of 51 or 50.450, etc... ---- Manual Page -- http://www.php.net/manual/en/function.number-format.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40006 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40006&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40006&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65350) next »