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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 04:01:23 2020 UTC