Annotation of embedaddon/php/ext/standard/tests/array/array_fill_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
10: echo "*** 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
16: Hello
17: HERE_DOC;
18:
19: // array of possible valid values for 'val' arugment
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;
33: for($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:
43: echo "Done";
44: ?>
45: --EXPECTF--
46: *** Testing array_fill() : basic functionality ***
47: -- Iteration 1 --
48: array(2) {
49: [0]=>
50: NULL
51: [1]=>
52: NULL
53: }
54: -- Iteration 2 --
55: array(2) {
56: [0]=>
57: int(0)
58: [1]=>
59: int(0)
60: }
61: -- Iteration 3 --
62: array(2) {
63: [0]=>
64: int(1)
65: [1]=>
66: int(1)
67: }
68: -- Iteration 4 --
69: array(2) {
70: [0]=>
71: float(1.5)
72: [1]=>
73: float(1.5)
74: }
75: -- Iteration 5 --
76: array(2) {
77: [0]=>
78: string(2) "hi"
79: [1]=>
80: string(2) "hi"
81: }
82: -- Iteration 6 --
83: array(2) {
84: [0]=>
85: string(2) "hi"
86: [1]=>
87: string(2) "hi"
88: }
89: -- Iteration 7 --
90: array(2) {
91: [0]=>
92: string(5) "Hello"
93: [1]=>
94: string(5) "Hello"
95: }
96: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>