1--TEST--
2Test array_values() function
3--INI--
4precision=14
5--FILE--
6<?php
7echo "*** Testing array_values() on basic array ***\n";
8$basic_arr = array( 1, 2, 2.0, "asdasd", array(1,2,3) );
9var_dump( array_values($basic_arr) );
10
11echo "\n*** Testing array_values() on various arrays ***";
12$arrays = array (
13  array(),
14  array(0),
15  array(-1),
16  array( array() ),
17  array("Hello"),
18  array(""),
19  array("", array()),
20  array(1,2,3),
21  array(1,2,3, array()),
22  array(1,2,3, array(4,6)),
23  array("a" => 1, "b" => 2, "c" =>3),
24  array(0 => 0, 1 => 1, 2 => 2),
25  array(TRUE, FALSE, NULL, true, false, null, "TRUE", "FALSE",
26        "NULL", "\x000", "\000"),
27  array("Hi" => 1, "Hello" => 2, "World" => 3),
28  array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ),
29  array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(), ""=>"" )
30);
31
32$i = 0;
33/* loop through to test array_values() with different arrays given above */
34foreach ($arrays as $array) {
35  echo "\n-- Iteration $i --\n";
36  var_dump( array_values($array) );
37  $i++;
38}
39
40echo "Done\n";
41?>
42--EXPECTF--
43*** Testing array_values() on basic array ***
44array(5) {
45  [0]=>
46  int(1)
47  [1]=>
48  int(2)
49  [2]=>
50  float(2)
51  [3]=>
52  string(6) "asdasd"
53  [4]=>
54  array(3) {
55    [0]=>
56    int(1)
57    [1]=>
58    int(2)
59    [2]=>
60    int(3)
61  }
62}
63
64*** Testing array_values() on various arrays ***
65-- Iteration 0 --
66array(0) {
67}
68
69-- Iteration 1 --
70array(1) {
71  [0]=>
72  int(0)
73}
74
75-- Iteration 2 --
76array(1) {
77  [0]=>
78  int(-1)
79}
80
81-- Iteration 3 --
82array(1) {
83  [0]=>
84  array(0) {
85  }
86}
87
88-- Iteration 4 --
89array(1) {
90  [0]=>
91  string(5) "Hello"
92}
93
94-- Iteration 5 --
95array(1) {
96  [0]=>
97  string(0) ""
98}
99
100-- Iteration 6 --
101array(2) {
102  [0]=>
103  string(0) ""
104  [1]=>
105  array(0) {
106  }
107}
108
109-- Iteration 7 --
110array(3) {
111  [0]=>
112  int(1)
113  [1]=>
114  int(2)
115  [2]=>
116  int(3)
117}
118
119-- Iteration 8 --
120array(4) {
121  [0]=>
122  int(1)
123  [1]=>
124  int(2)
125  [2]=>
126  int(3)
127  [3]=>
128  array(0) {
129  }
130}
131
132-- Iteration 9 --
133array(4) {
134  [0]=>
135  int(1)
136  [1]=>
137  int(2)
138  [2]=>
139  int(3)
140  [3]=>
141  array(2) {
142    [0]=>
143    int(4)
144    [1]=>
145    int(6)
146  }
147}
148
149-- Iteration 10 --
150array(3) {
151  [0]=>
152  int(1)
153  [1]=>
154  int(2)
155  [2]=>
156  int(3)
157}
158
159-- Iteration 11 --
160array(3) {
161  [0]=>
162  int(0)
163  [1]=>
164  int(1)
165  [2]=>
166  int(2)
167}
168
169-- Iteration 12 --
170array(11) {
171  [0]=>
172  bool(true)
173  [1]=>
174  bool(false)
175  [2]=>
176  NULL
177  [3]=>
178  bool(true)
179  [4]=>
180  bool(false)
181  [5]=>
182  NULL
183  [6]=>
184  string(4) "TRUE"
185  [7]=>
186  string(5) "FALSE"
187  [8]=>
188  string(4) "NULL"
189  [9]=>
190  string(2) "%00"
191  [10]=>
192  string(1) "%0"
193}
194
195-- Iteration 13 --
196array(3) {
197  [0]=>
198  int(1)
199  [1]=>
200  int(2)
201  [2]=>
202  int(3)
203}
204
205-- Iteration 14 --
206array(3) {
207  [0]=>
208  string(0) ""
209  [1]=>
210  int(-6)
211  [2]=>
212  float(-0.5)
213}
214
215-- Iteration 15 --
216array(4) {
217  [0]=>
218  array(0) {
219  }
220  [1]=>
221  array(1) {
222    [0]=>
223    int(0)
224  }
225  [2]=>
226  array(1) {
227    [0]=>
228    int(1)
229  }
230  [3]=>
231  string(0) ""
232}
233Done
234