note 125492 added to class.numberformatter
| From: | stan at dragnev dot ca | Date: | Fri, 06 Nov 2020 16:13:48 +0000 |
| Subject: | note 125492 added to class.numberformatter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215818@lists.php.net to get a copy of this message | ||
Here's an example of how to use PATTERN_DECIMAL to print a number with two fraction digits, use
() for negative numbers and pad to five characters to the left of the decimal point, using spaces as
the padding character:
<?php
$fmt = new NumberFormatter("en-CA", NumberFormatter::PATTERN_DECIMAL, "* #####.00 ;(*
#####.00)");
echo $fmt->format(-45.1);
// Outputs: " (45.10)"
?>
Note that the ; in the pattern denotes the beginning of a subpattern, which is used for negative
numbers. Hence the brackets around the pattern after the semicolon.
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.174 (proxied: 192.0.149.177)
----
Manual Page -- http://php.net/manual/en/class.numberformatter.php
Edit -- https://master.php.net/note/edit/125492
Del: integrated -- https://master.php.net/note/delete/125492/integrated
Del: useless -- https://master.php.net/note/delete/125492/useless
Del: bad code -- https://master.php.net/note/delete/125492/bad+code
Del: spam -- https://master.php.net/note/delete/125492/spam
Del: non-english -- https://master.php.net/note/delete/125492/non-english
Del: in docs -- https://master.php.net/note/delete/125492/in+docs
Del: other reasons-- https://master.php.net/note/delete/125492
Reject -- https://master.php.net/note/reject/125492
Search -- https://master.php.net/manage/user-notes.php