php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75025 \NumberFormatter::DECIMAL_ALWAYS_SHOWN return result with currency symbol
Submitted: 2017-08-02 16:17 UTC Modified: 2017-08-02 16:30 UTC
From: guyasyou at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 7.1.8RC1 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guyasyou at gmail dot com
New email:
PHP Version: OS:

 

 [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 $

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-02 16:30 UTC] guyasyou at gmail dot com
-Status: Open +Status: Closed
 [2017-08-02 16:30 UTC] guyasyou at gmail dot com
It was my mistake, correct version:
$formatter = \NumberFormatter::create('en_US', \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS , 2);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 22:01:27 2024 UTC