1--TEST--
2Test number_format() - basic function test number_format()
3--FILE--
4<?php
5$values = array(1234.5678,
6                -1234.5678,
7                1234.6578e4,
8                -1234.56789e4,
9                999999,
10                -999999,
11                999999.0,
12                -999999.0,
13                0x1234CDEF,
14                02777777777,
15                "123456789",
16                "123.456789",
17                "12.3456789e1",
18                true,
19                false);
20
21echo "\n number_format tests.....default\n";
22for ($i = 0; $i < count($values); $i++) {
23    $res = number_format($values[$i]);
24    var_dump($res);
25}
26
27echo "\n number_format tests.....with two dp\n";
28for ($i = 0; $i < count($values); $i++) {
29    $res = number_format($values[$i], 2);
30    var_dump($res);
31}
32
33echo "\n number_format tests.....English format\n";
34for ($i = 0; $i < count($values); $i++) {
35    $res = number_format($values[$i], 2, '.', ' ');
36    var_dump($res);
37}
38
39echo "\n number_format tests.....French format\n";
40for ($i = 0; $i < count($values); $i++) {
41    $res = number_format($values[$i], 2, ',' , ' ');
42    var_dump($res);
43}
44
45echo "\n number_format tests.....multichar format\n";
46for ($i = 0; $i < count($values); $i++) {
47    $res = number_format($values[$i], 2, ' DECIMALS ' , ' THOUSAND ');
48    var_dump($res);
49}
50?>
51--EXPECT--
52number_format tests.....default
53string(5) "1,235"
54string(6) "-1,235"
55string(10) "12,346,578"
56string(11) "-12,345,679"
57string(7) "999,999"
58string(8) "-999,999"
59string(7) "999,999"
60string(8) "-999,999"
61string(11) "305,450,479"
62string(11) "402,653,183"
63string(11) "123,456,789"
64string(3) "123"
65string(3) "123"
66string(1) "1"
67string(1) "0"
68
69 number_format tests.....with two dp
70string(8) "1,234.57"
71string(9) "-1,234.57"
72string(13) "12,346,578.00"
73string(14) "-12,345,678.90"
74string(10) "999,999.00"
75string(11) "-999,999.00"
76string(10) "999,999.00"
77string(11) "-999,999.00"
78string(14) "305,450,479.00"
79string(14) "402,653,183.00"
80string(14) "123,456,789.00"
81string(6) "123.46"
82string(6) "123.46"
83string(4) "1.00"
84string(4) "0.00"
85
86 number_format tests.....English format
87string(8) "1 234.57"
88string(9) "-1 234.57"
89string(13) "12 346 578.00"
90string(14) "-12 345 678.90"
91string(10) "999 999.00"
92string(11) "-999 999.00"
93string(10) "999 999.00"
94string(11) "-999 999.00"
95string(14) "305 450 479.00"
96string(14) "402 653 183.00"
97string(14) "123 456 789.00"
98string(6) "123.46"
99string(6) "123.46"
100string(4) "1.00"
101string(4) "0.00"
102
103 number_format tests.....French format
104string(8) "1 234,57"
105string(9) "-1 234,57"
106string(13) "12 346 578,00"
107string(14) "-12 345 678,90"
108string(10) "999 999,00"
109string(11) "-999 999,00"
110string(10) "999 999,00"
111string(11) "-999 999,00"
112string(14) "305 450 479,00"
113string(14) "402 653 183,00"
114string(14) "123 456 789,00"
115string(6) "123,46"
116string(6) "123,46"
117string(4) "1,00"
118string(4) "0,00"
119
120 number_format tests.....multichar format
121string(26) "1 THOUSAND 234 DECIMALS 57"
122string(27) "-1 THOUSAND 234 DECIMALS 57"
123string(40) "12 THOUSAND 346 THOUSAND 578 DECIMALS 00"
124string(41) "-12 THOUSAND 345 THOUSAND 678 DECIMALS 90"
125string(28) "999 THOUSAND 999 DECIMALS 00"
126string(29) "-999 THOUSAND 999 DECIMALS 00"
127string(28) "999 THOUSAND 999 DECIMALS 00"
128string(29) "-999 THOUSAND 999 DECIMALS 00"
129string(41) "305 THOUSAND 450 THOUSAND 479 DECIMALS 00"
130string(41) "402 THOUSAND 653 THOUSAND 183 DECIMALS 00"
131string(41) "123 THOUSAND 456 THOUSAND 789 DECIMALS 00"
132string(15) "123 DECIMALS 46"
133string(15) "123 DECIMALS 46"
134string(13) "1 DECIMALS 00"
135string(13) "0 DECIMALS 00"
136