php.net |  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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dcaylor at maf dot org
New email:
PHP Version: OS:

 

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 13:55 UTC] hholzgra@php.net
sounds like good old BASICs "PRINT USING ..." ?
 [2010-12-17 13:16 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2010-12-17 13:16 UTC] jani@php.net
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-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC