1--TEST--
2Test array_fill() function : usage variations - different types of array values for 'val' argument
3--FILE--
4<?php
5/*
6 * testing array_fill() by passing different types of array  values for 'val' argument
7 */
8
9echo "*** Testing array_fill() : usage variations ***\n";
10
11// Initialise function arguments not being substituted
12$start_key = 0;
13$num = 2;
14
15
16//array of different types of array values for 'val' argument
17$values = array(
18
19  /* 1  */  array(),
20            array(1 , 2 , 3 , 4),
21            array(1 => "Hi" , 2 => "Hello"),
22            array("Saffron" , "White" , "Green"),
23  /* 5  */  array('color' => 'red' , 'item' => 'pen'),
24            array( 'color' => 'red' , 2 => 'green ' ),
25            array("colour" => "red" , "item" => "pen"),
26            array( TRUE => "red" , FALSE => "green" ),
27            array( true => "red" , FALSE => "green" ),
28  /* 10 */  array( 1 => "Hi" , "color" => "red" , 'item' => 'pen'),
29            array( NULL => "Hi", '1' => "Hello" , "1" => "Green"),
30            array( ""=>1, "color" => "green"),
31  /* 13 */  array('Saffron' , 'White' , 'Green')
32);
33
34// loop through each element of the values array for 'val' argument
35// check the working of array_fill()
36echo "--- Testing array_fill() with different types of array values for 'val' argument ---\n";
37$counter = 1;
38for($i = 0; $i < count($values); $i++)
39{
40  echo "-- Iteration $counter --\n";
41  $val = $values[$i];
42
43  var_dump( array_fill($start_key , $num , $val) );
44
45  $counter++;
46}
47
48echo "Done";
49?>
50--EXPECT--
51*** Testing array_fill() : usage variations ***
52--- Testing array_fill() with different types of array values for 'val' argument ---
53-- Iteration 1 --
54array(2) {
55  [0]=>
56  array(0) {
57  }
58  [1]=>
59  array(0) {
60  }
61}
62-- Iteration 2 --
63array(2) {
64  [0]=>
65  array(4) {
66    [0]=>
67    int(1)
68    [1]=>
69    int(2)
70    [2]=>
71    int(3)
72    [3]=>
73    int(4)
74  }
75  [1]=>
76  array(4) {
77    [0]=>
78    int(1)
79    [1]=>
80    int(2)
81    [2]=>
82    int(3)
83    [3]=>
84    int(4)
85  }
86}
87-- Iteration 3 --
88array(2) {
89  [0]=>
90  array(2) {
91    [1]=>
92    string(2) "Hi"
93    [2]=>
94    string(5) "Hello"
95  }
96  [1]=>
97  array(2) {
98    [1]=>
99    string(2) "Hi"
100    [2]=>
101    string(5) "Hello"
102  }
103}
104-- Iteration 4 --
105array(2) {
106  [0]=>
107  array(3) {
108    [0]=>
109    string(7) "Saffron"
110    [1]=>
111    string(5) "White"
112    [2]=>
113    string(5) "Green"
114  }
115  [1]=>
116  array(3) {
117    [0]=>
118    string(7) "Saffron"
119    [1]=>
120    string(5) "White"
121    [2]=>
122    string(5) "Green"
123  }
124}
125-- Iteration 5 --
126array(2) {
127  [0]=>
128  array(2) {
129    ["color"]=>
130    string(3) "red"
131    ["item"]=>
132    string(3) "pen"
133  }
134  [1]=>
135  array(2) {
136    ["color"]=>
137    string(3) "red"
138    ["item"]=>
139    string(3) "pen"
140  }
141}
142-- Iteration 6 --
143array(2) {
144  [0]=>
145  array(2) {
146    ["color"]=>
147    string(3) "red"
148    [2]=>
149    string(6) "green "
150  }
151  [1]=>
152  array(2) {
153    ["color"]=>
154    string(3) "red"
155    [2]=>
156    string(6) "green "
157  }
158}
159-- Iteration 7 --
160array(2) {
161  [0]=>
162  array(2) {
163    ["colour"]=>
164    string(3) "red"
165    ["item"]=>
166    string(3) "pen"
167  }
168  [1]=>
169  array(2) {
170    ["colour"]=>
171    string(3) "red"
172    ["item"]=>
173    string(3) "pen"
174  }
175}
176-- Iteration 8 --
177array(2) {
178  [0]=>
179  array(2) {
180    [1]=>
181    string(3) "red"
182    [0]=>
183    string(5) "green"
184  }
185  [1]=>
186  array(2) {
187    [1]=>
188    string(3) "red"
189    [0]=>
190    string(5) "green"
191  }
192}
193-- Iteration 9 --
194array(2) {
195  [0]=>
196  array(2) {
197    [1]=>
198    string(3) "red"
199    [0]=>
200    string(5) "green"
201  }
202  [1]=>
203  array(2) {
204    [1]=>
205    string(3) "red"
206    [0]=>
207    string(5) "green"
208  }
209}
210-- Iteration 10 --
211array(2) {
212  [0]=>
213  array(3) {
214    [1]=>
215    string(2) "Hi"
216    ["color"]=>
217    string(3) "red"
218    ["item"]=>
219    string(3) "pen"
220  }
221  [1]=>
222  array(3) {
223    [1]=>
224    string(2) "Hi"
225    ["color"]=>
226    string(3) "red"
227    ["item"]=>
228    string(3) "pen"
229  }
230}
231-- Iteration 11 --
232array(2) {
233  [0]=>
234  array(2) {
235    [""]=>
236    string(2) "Hi"
237    [1]=>
238    string(5) "Green"
239  }
240  [1]=>
241  array(2) {
242    [""]=>
243    string(2) "Hi"
244    [1]=>
245    string(5) "Green"
246  }
247}
248-- Iteration 12 --
249array(2) {
250  [0]=>
251  array(2) {
252    [""]=>
253    int(1)
254    ["color"]=>
255    string(5) "green"
256  }
257  [1]=>
258  array(2) {
259    [""]=>
260    int(1)
261    ["color"]=>
262    string(5) "green"
263  }
264}
265-- Iteration 13 --
266array(2) {
267  [0]=>
268  array(3) {
269    [0]=>
270    string(7) "Saffron"
271    [1]=>
272    string(5) "White"
273    [2]=>
274    string(5) "Green"
275  }
276  [1]=>
277  array(3) {
278    [0]=>
279    string(7) "Saffron"
280    [1]=>
281    string(5) "White"
282    [2]=>
283    string(5) "Green"
284  }
285}
286Done
287