note 67153 deleted from function.number-format by cmb
| From: | cmb@php.net | Date: | Sun, 08 Sep 2019 10:21:52 +0000 |
| Subject: | note 67153 deleted from function.number-format by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212133@lists.php.net to get a copy of this message | ||
Note Submitter:
----
The modification to number_format below does what I actually want it to do, with currency, for
example. I want it to show $1.40 and not $1.4 or $1.400 - except in the rare case where I have
$1.435 for something, in which case I *don't* want it to round. The ugliness below serves my
purpose.
function nof($number,$decimals) {
if (number_format($number,$decimals,'.',',') != $number) {
return $number;
} else {
return number_format($number,$decimals,'.',',');
}
}