1--TEST--
2Test array_fill() function : basic functionality
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
10echo "*** Testing array_fill() : basic functionality ***\n";
11
12// calling the array_fill with all possible valid values for 'val' argument
13$start_key = 0 ;
14$num = 2;
15$heredoc = <<<HERE_DOC
16Hello
17HERE_DOC;
18
19// array of possible valid values for 'val' argument
20$values = array (
21
22  /* 1  */  NULL,
23            0,
24            1,
25  /* 4  */  1.5,
26            'hi',
27            "hi",
28  /* 7  */  $heredoc
29
30);
31
32$counter = 1;
33for($i = 0; $i < count($values); $i ++)
34{
35  echo "-- Iteration $counter --\n";
36  $val = $values[$i];
37
38  var_dump( array_fill($start_key,$num,$val) );
39
40  $counter++;
41}
42
43echo "Done";
44?>
45--EXPECTF--
46*** Testing array_fill() : basic functionality ***
47-- Iteration 1 --
48array(2) {
49  [0]=>
50  NULL
51  [1]=>
52  NULL
53}
54-- Iteration 2 --
55array(2) {
56  [0]=>
57  int(0)
58  [1]=>
59  int(0)
60}
61-- Iteration 3 --
62array(2) {
63  [0]=>
64  int(1)
65  [1]=>
66  int(1)
67}
68-- Iteration 4 --
69array(2) {
70  [0]=>
71  float(1.5)
72  [1]=>
73  float(1.5)
74}
75-- Iteration 5 --
76array(2) {
77  [0]=>
78  string(2) "hi"
79  [1]=>
80  string(2) "hi"
81}
82-- Iteration 6 --
83array(2) {
84  [0]=>
85  string(2) "hi"
86  [1]=>
87  string(2) "hi"
88}
89-- Iteration 7 --
90array(2) {
91  [0]=>
92  string(5) "Hello"
93  [1]=>
94  string(5) "Hello"
95}
96Done
97