1--TEST--
2Test array_fill() function : usage variations - using return value of array_fill for 'val' argument
3--FILE--
4<?php
5/* Prototype  : proto array array_fill(int start_key, int num, mixed val)
6 * Description: Create an array containing num elements starting with index start_key each initialized to val
7 * Source code: ext/standard/array.c
8 */
9
10/* passing array_fill() as the 'val' argument in array_fill() function */
11
12echo "*** Testing array_fill() : variation ***\n";
13
14$start_key = 0;
15$num = 2;
16$heredoc = <<<HERE_DOC
17Hello
18HERE_DOC;
19
20// array of possible valid values for 'val' argument
21$values = array (
22
23  /* 1  */  NULL,
24            0,
25            1,
26  /* 4  */  1.0,
27            'hi',
28            "hi",
29  /* 7  */  $heredoc
30);
31
32echo "*** Filling 2 dimensional array with all basic valid values ***\n";
33$counter = 1;
34for($i =0; $i < count($values); $i ++)
35{
36  echo "-- Iteration $counter --\n";
37  $val = $values[$i];
38
39  var_dump( array_fill($start_key,$num,array_fill($start_key,$num,$val)) );
40
41  $counter++;
42}
43
44echo "Done";
45?>
46--EXPECTF--
47*** Testing array_fill() : variation ***
48*** Filling 2 dimensional array with all basic valid values ***
49-- Iteration 1 --
50array(2) {
51  [0]=>
52  array(2) {
53    [0]=>
54    NULL
55    [1]=>
56    NULL
57  }
58  [1]=>
59  array(2) {
60    [0]=>
61    NULL
62    [1]=>
63    NULL
64  }
65}
66-- Iteration 2 --
67array(2) {
68  [0]=>
69  array(2) {
70    [0]=>
71    int(0)
72    [1]=>
73    int(0)
74  }
75  [1]=>
76  array(2) {
77    [0]=>
78    int(0)
79    [1]=>
80    int(0)
81  }
82}
83-- Iteration 3 --
84array(2) {
85  [0]=>
86  array(2) {
87    [0]=>
88    int(1)
89    [1]=>
90    int(1)
91  }
92  [1]=>
93  array(2) {
94    [0]=>
95    int(1)
96    [1]=>
97    int(1)
98  }
99}
100-- Iteration 4 --
101array(2) {
102  [0]=>
103  array(2) {
104    [0]=>
105    float(1)
106    [1]=>
107    float(1)
108  }
109  [1]=>
110  array(2) {
111    [0]=>
112    float(1)
113    [1]=>
114    float(1)
115  }
116}
117-- Iteration 5 --
118array(2) {
119  [0]=>
120  array(2) {
121    [0]=>
122    string(2) "hi"
123    [1]=>
124    string(2) "hi"
125  }
126  [1]=>
127  array(2) {
128    [0]=>
129    string(2) "hi"
130    [1]=>
131    string(2) "hi"
132  }
133}
134-- Iteration 6 --
135array(2) {
136  [0]=>
137  array(2) {
138    [0]=>
139    string(2) "hi"
140    [1]=>
141    string(2) "hi"
142  }
143  [1]=>
144  array(2) {
145    [0]=>
146    string(2) "hi"
147    [1]=>
148    string(2) "hi"
149  }
150}
151-- Iteration 7 --
152array(2) {
153  [0]=>
154  array(2) {
155    [0]=>
156    string(5) "Hello"
157    [1]=>
158    string(5) "Hello"
159  }
160  [1]=>
161  array(2) {
162    [0]=>
163    string(5) "Hello"
164    [1]=>
165    string(5) "Hello"
166  }
167}
168Done
169