php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63165 Error with "%.0n" for windows replacement formula of money-format
Submitted: 2012-09-26 17:14 UTC Modified: 2021-06-30 15:21 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: somadden at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: Strings related
PHP Version: Irrelevant OS: window 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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: somadden at gmail dot com
New email:
PHP Version: OS:

 

 [2012-09-26 17:14 UTC] somadden at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.money-format
---
In the user posted formula for windows

replace:
$right      = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits'];

with:
$right      = (trim($fmatch[4]) || trim($fmatch[4]) === '0' ) ? (int)$fmatch[4] : 
$locale['int_frac_digits'];

Test script:
---------------
echo money_format('%.0n', 20000);

Expected result:
----------------
20000

Actual result:
--------------
20000.00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-15 17:47 UTC] ppaisndud at gmail dot com
This a problem with user notes.
 [2017-01-28 12:20 UTC] cmb@php.net
-Package: Documentation problem +Package: Strings related
 [2021-06-30 15:21 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-06-30 15:21 UTC] cmb@php.net
Given that money_format() is deprecated as of PHP 7.4.0, and
removed as of PHP 8.0.0 for good reasons (never ever store
monetary values float), this user note will not be fixed.
Actually, it would be better to remove these notes, since fallback
implementations clearly belong somewhere else.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 09:03:36 2021 UTC