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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC