|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13011 formatting numbers
Submitted: 2001-08-28 20:45 UTC Modified: 2010-12-17 13:16 UTC
From: dcaylor at maf dot org Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.0.4pl1 OS: Linux 7.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-08-28 20:45 UTC] dcaylor at maf dot org
It would be extremely helpful to be able to do more formatting of numbers than is currently available.  
Specifically, it would be good if number_format would prepend a dollar sign or allow negative numbers to be shown in brackets rather than with a negative sign.  Both of these are necessary for accounting applications.

My current solution for negative currency looks like this: 
  if ( $value < 0 )
    $value = "(\$".number_format(abs($value),2).")";
which works but is less than ideal.  For one thing, it makes later use of the number difficult.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 13:55 UTC]
sounds like good old BASICs "PRINT USING ..." ?
 [2010-12-17 13:16 UTC]
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2010-12-17 13:16 UTC]
As you have shown, it's very easy to achieve in userland. Not everything and their mom need to have their own native functions and such in PHP..
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Oct 22 06:01:26 2018 UTC