note 32389 added to function.number-format
| From: | rpuchalsky at att dot net | Date: | Mon, 26 May 2003 14:38:14 +0000 |
| Subject: | note 32389 added to function.number-format | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49035@lists.php.net to get a copy of this message | ||
What I wanted to do was use number_format on decimal
numbers with uncertain precision, in cases where I wanted
to preserve whatever was to the right of the decimal point
without truncating it. I did this by using:
$pieces = explode(".", $decimal_number);
$formatted_number = number_format($pieces[0]) . "." .
rtrim($pieces[1],"0");
Note that rtrim with a second parameter will only work for PHP 4.1., so I actually used a different
(database-dependent) solution for that part.
----
Manual Page -- http://www.php.net/manual/en/function.number-format.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32389
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32389&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32389&report=yes