reference/strings/functions/number-format.xml
de35b538453a7817a0cc839cddda0be46eed8764
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.number-format" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+
<refentry xml:id="function.number-format" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
<refnamediv>
5
5
<refname>number_format</refname>
6
6
<refpurpose>Format a number with grouped thousands</refpurpose>
...
...
@@ -10,36 +10,13 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>number_format</methodname>
13
-
<methodparam><type>float</type><parameter>number</parameter></methodparam>
13
+
<methodparam><type>float</type><parameter>num</parameter></methodparam>
14
14
<methodparam choice="opt"><type>int</type><parameter>decimals</parameter><initializer>0</initializer></methodparam>
15
-
</methodsynopsis>
16
-
<methodsynopsis>
17
-
<type>string</type><methodname>number_format</methodname>
18
-
<methodparam><type>float</type><parameter>number</parameter></methodparam>
19
-
<methodparam><type>int</type><parameter>decimals</parameter><initializer>0</initializer></methodparam>
20
-
<methodparam><type>string</type><parameter>dec_point</parameter><initializer>"."</initializer></methodparam>
21
-
<methodparam><type>string</type><parameter>thousands_sep</parameter><initializer>","</initializer></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>decimal_separator</parameter><initializer>"."</initializer></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>thousands_separator</parameter><initializer>","</initializer></methodparam>
22
17
</methodsynopsis>
23
18
<para>
24
-
This function accepts either one, two, or four parameters (not three):
25
-
</para>
26
-
<para>
27
-
If only one parameter is given,
28
-
<parameter>number</parameter> will be formatted without decimals,
29
-
but with a comma (",") between every group of thousands.
30
-
</para>
31
-
<para>
32
-
If two parameters are given, <parameter>number</parameter> will
33
-
be formatted with <parameter>decimals</parameter> decimals with a
34
-
dot (".") in front, and a comma (",") between every group of
35
-
thousands.
36
-
</para>
37
-
<para>
38
-
If all four parameters are given, <parameter>number</parameter>
39
-
will be formatted with <parameter>decimals</parameter> decimals,
40
-
<parameter>dec_point</parameter> instead of a dot (".") before
41
-
the decimals and <parameter>thousands_sep</parameter> instead of
42
-
a comma (",") between every group of thousands.
19
+
Formats a number with grouped thousands and optionally decimal digits using the rounding half up rule.
43
20
</para>
44
21
</refsect1>
45
22

...
...
@@ -48,7 +25,7 @@
48
25
<para>
49
26
<variablelist>
50
27
<varlistentry>
51
-
<term><parameter>number</parameter></term>
28
+
<term><parameter>num</parameter></term>
52
29
<listitem>
53
30
<para>
54
31
The number being formatted.
...
...
@@ -59,12 +36,14 @@
59
36
<term><parameter>decimals</parameter></term>
60
37
<listitem>
61
38
<para>
62
-
Sets the number of decimal points.
39
+
Sets the number of decimal digits.
40
+
If <literal>0</literal>, the <parameter>decimal_separator</parameter> is
41
+
omitted from the return value.
63
42
</para>
64
43
</listitem>
65
44
</varlistentry>
66
45
<varlistentry>
67
-
<term><parameter>dec_point</parameter></term>
46
+
<term><parameter>decimal_separator</parameter></term>
68
47
<listitem>
69
48
<para>
70
49
Sets the separator for the decimal point.
...
...
@@ -72,7 +51,7 @@
72
51
</listitem>
73
52
</varlistentry>
74
53
<varlistentry>
75
-
<term><parameter>thousands_sep</parameter></term>
54
+
<term><parameter>thousands_separator</parameter></term>
76
55
<listitem>
77
56
<para>
78
57
Sets the thousands separator.
...
...
@@ -86,7 +65,7 @@
86
65
<refsect1 role="returnvalues">
87
66
&reftitle.returnvalues;
88
67
<para>
89
-
A formatted version of <parameter>number</parameter>.
68
+
A formatted version of <parameter>num</parameter>.
90
69
</para>
91
70
</refsect1>
92
71

...
...
@@ -103,12 +82,18 @@
103
82
</thead>
104
83
<tbody>
105
84
<row>
106
-
<entry>5.4.0</entry>
85
+
<entry>8.0.0</entry>
107
86
<entry>
108
-
This function now supports multiple bytes in
109
-
<parameter>dec_point</parameter> and
110
-
<parameter>thousands_sep</parameter>. Only the first byte of each
111
-
separator was used in older versions.
87
+
Prior to this version, <function>number_format</function> accepted
88
+
one, two, or four parameters (but not three).
89
+
</entry>
90
+
</row>
91
+
<row>
92
+
<entry>7.2.0</entry>
93
+
<entry>
94
+
<function>number_format</function> was changed to not being able to return
95
+
<literal>-0</literal>, previously <literal>-0</literal> could be returned
96
+
for cases like where <parameter>num</parameter> would be <literal>-0.01</literal>.
112
97
</entry>
113
98
</row>
114
99
</tbody>
...
...
@@ -125,7 +110,7 @@
125
110
<para>
126
111
For instance, French notation usually use two decimals,
127
112
comma (',') as decimal separator, and space (' ') as
128
-
thousand separator. The following example demonstrates various way to format a number:
113
+
thousand separator. The following example demonstrates various ways to format a number:
129
114
</para>
130
115
<programlisting role="php">
131
116
<![CDATA[
...
...
@@ -154,32 +139,6 @@ $english_format_number = number_format($number, 2, '.', '');
154
139
</para>
155
140
</refsect1>
156
141
157
-
<refsect1 role="changelog">
158
-
&reftitle.changelog;
159
-
<para>
160
-
<informaltable>
161
-
<tgroup cols="2">
162
-
<thead>
163
-
<row>
164
-
<entry>&Version;</entry>
165
-
<entry>&Description;</entry>
166
-
</row>
167
-
</thead>
168
-
<tbody>
169
-
<row>
170
-
<entry>7.2.0</entry>
171
-
<entry>
172
-
<function>number_format</function> was changed to not being able to return
173
-
<literal>-0</literal>, previously <literal>-0</literal> could be returned
174
-
for cases like where <parameter>number</parameter> would be <literal>-0.01</literal>.
175
-
</entry>
176
-
</row>
177
-
</tbody>
178
-
</tgroup>
179
-
</informaltable>
180
-
</para>
181
-
</refsect1>
182
-

183
142
<refsect1 role="seealso">
184
143
&reftitle.seealso;
185
144
<para>
186
145