summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/array_pad_variation7.phpt
blob: 06f2bfa68be509e964d2c31e10a47f945a9feb45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
--TEST--
Test array_pad() function : usage variations - two dimensional array for 'input' argument
--FILE--
<?php
/*
* Passing two dimensional array to $input argument and testing whether
* array_pad() behaves in an expected way with the other arguments passed to the function.
* The $pad_size and $pad_value arguments passed are fixed values.
*/

echo "*** Testing array_pad() : Passing 2-D array to \$input argument ***\n";

// initialize the 2-d array
$input = array (
  array(1, 2, 3),
  array("hello", 'world'),
  array("one" => 1, "two" => 2)
);

// initialize the $pad_size and $pad_value arguments
$pad_size = 5;
$pad_value = "HELLO";

// entire 2-d array
echo "-- Entire 2-d array for \$input argument --\n";
var_dump( array_pad($input, $pad_size, $pad_value) );  // positive 'pad_size'
var_dump( array_pad($input, -$pad_size, $pad_value) );  // negative 'pad_size'

// sub array
echo "-- Sub array for \$input argument --\n";
var_dump( array_pad($input[1], $pad_size, $pad_value) );  // positive 'pad_size'
var_dump( array_pad($input[1], -$pad_size, $pad_value) );  // negative 'pad_size'

echo "Done";
?>
--EXPECT--
*** Testing array_pad() : Passing 2-D array to $input argument ***
-- Entire 2-d array for $input argument --
array(5) {
  [0]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
  [1]=>
  array(2) {
    [0]=>
    string(5) "hello"
    [1]=>
    string(5) "world"
  }
  [2]=>
  array(2) {
    ["one"]=>
    int(1)
    ["two"]=>
    int(2)
  }
  [3]=>
  string(5) "HELLO"
  [4]=>
  string(5) "HELLO"
}
array(5) {
  [0]=>
  string(5) "HELLO"
  [1]=>
  string(5) "HELLO"
  [2]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
  [3]=>
  array(2) {
    [0]=>
    string(5) "hello"
    [1]=>
    string(5) "world"
  }
  [4]=>
  array(2) {
    ["one"]=>
    int(1)
    ["two"]=>
    int(2)
  }
}
-- Sub array for $input argument --
array(5) {
  [0]=>
  string(5) "hello"
  [1]=>
  string(5) "world"
  [2]=>
  string(5) "HELLO"
  [3]=>
  string(5) "HELLO"
  [4]=>
  string(5) "HELLO"
}
array(5) {
  [0]=>
  string(5) "HELLO"
  [1]=>
  string(5) "HELLO"
  [2]=>
  string(5) "HELLO"
  [3]=>
  string(5) "hello"
  [4]=>
  string(5) "world"
}
Done