|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-08-02 16:17 UTC] guyasyou at gmail dot com
Description:
------------
\NumberFormatter with param \NumberFormatter::DECIMAL_ALWAYS_SHOWN return result with currency symbol. is it normal?
Test script:
---------------
$amounts = [
1234,
123456.78,
-1234.05607089,
.5648671,
165.00000,
];
$formatter = \NumberFormatter::create('us_US', \NumberFormatter::DECIMAL_ALWAYS_SHOWN);
foreach ($amounts as $amount) {
print($formatter->format($amount).'<br/>');
}
Expected result:
----------------
1 234,00
123 456,78
-1 234,06
0,56
165,00
Actual result:
--------------
1 234,00 $
123 456,78 $
-1 234,06 $
0,56 $
165,00 $
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 15:00:01 2025 UTC |
It was my mistake, correct version: $formatter = \NumberFormatter::create('en_US', \NumberFormatter::DECIMAL); $formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS , 2);