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