Doc #63165 [Opn->Wfx]: Error with "%.0n" for windows replacement formula of money-format

From: Date: Wed, 30 Jun 2021 15:21:25 +0000
Subject: Doc #63165 [Opn->Wfx]: Error with "%.0n" for windows replacement formula of money-format
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18912@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63165&edit=1 ID: 63165 Updated by: cmb@php.net Reported by: somadden at gmail dot com Summary: Error with "%.0n" for windows replacement formula of money-format -Status: Open +Status: Wont fix Type: Documentation Problem Package: Strings related Operating System: window 7 PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2015-04-15 17:47:38] ppaisndud at gmail dot com This a problem with user notes. ------------------------------------------------------------------------ [2012-09-26 17:14:05] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63165&edit=1

« previous php.doc.bugs (#18912) next »