note 52311 added to function.number-format
| From: | stm555 at hotmail dot com | Date: | Wed, 27 Apr 2005 15:54:44 +0000 |
| Subject: | note 52311 added to function.number-format | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88641@lists.php.net to get a copy of this message | ||
I ran across an issue where I wanted to keep the entered precision of a real value, without
arbitrarily rounding off what the user had submitted.
I figured it out with a quick explode on the number before formatting. I could then format either
side of the decimal.
<?php
function number_format_unlimited_precision($number,$decimal = '.')
{
$broken_number = explode($decimal,$number);
return number_format($broken_number[0]).$decimal.$broken_number[1];
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.number-format.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52311
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52311&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52311&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52311&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52311&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52311&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52311&report=yes
Search -- http://master.php.net/manage/user-notes.php