1--TEST--
2Test array_pad() function : usage variations - two dimensional array for 'input' argument
3--FILE--
4<?php
5/* Prototype  : array array_pad(array $input, int $pad_size, mixed $pad_value)
6 * Description: Returns a copy of input array padded with pad_value to size pad_size
7 * Source code: ext/standard/array.c
8*/
9
10/*
11* Passing two dimensional array to $input argument and testing whether
12* array_pad() behaves in an expected way with the other arguments passed to the function.
13* The $pad_size and $pad_value arguments passed are fixed values.
14*/
15
16echo "*** Testing array_pad() : Passing 2-D array to \$input argument ***\n";
17
18// initialize the 2-d array
19$input = array (
20  array(1, 2, 3),
21  array("hello", 'world'),
22  array("one" => 1, "two" => 2)
23);
24
25// initialize the $pad_size and $pad_value arguments
26$pad_size = 5;
27$pad_value = "HELLO";
28
29// entire 2-d array
30echo "-- Entire 2-d array for \$input argument --\n";
31var_dump( array_pad($input, $pad_size, $pad_value) );  // positive 'pad_size'
32var_dump( array_pad($input, -$pad_size, $pad_value) );  // negative 'pad_size'
33
34// sub array
35echo "-- Sub array for \$input argument --\n";
36var_dump( array_pad($input[1], $pad_size, $pad_value) );  // positive 'pad_size'
37var_dump( array_pad($input[1], -$pad_size, $pad_value) );  // negative 'pad_size'
38
39echo "Done";
40?>
41--EXPECT--
42*** Testing array_pad() : Passing 2-D array to $input argument ***
43-- Entire 2-d array for $input argument --
44array(5) {
45  [0]=>
46  array(3) {
47    [0]=>
48    int(1)
49    [1]=>
50    int(2)
51    [2]=>
52    int(3)
53  }
54  [1]=>
55  array(2) {
56    [0]=>
57    string(5) "hello"
58    [1]=>
59    string(5) "world"
60  }
61  [2]=>
62  array(2) {
63    ["one"]=>
64    int(1)
65    ["two"]=>
66    int(2)
67  }
68  [3]=>
69  string(5) "HELLO"
70  [4]=>
71  string(5) "HELLO"
72}
73array(5) {
74  [0]=>
75  string(5) "HELLO"
76  [1]=>
77  string(5) "HELLO"
78  [2]=>
79  array(3) {
80    [0]=>
81    int(1)
82    [1]=>
83    int(2)
84    [2]=>
85    int(3)
86  }
87  [3]=>
88  array(2) {
89    [0]=>
90    string(5) "hello"
91    [1]=>
92    string(5) "world"
93  }
94  [4]=>
95  array(2) {
96    ["one"]=>
97    int(1)
98    ["two"]=>
99    int(2)
100  }
101}
102-- Sub array for $input argument --
103array(5) {
104  [0]=>
105  string(5) "hello"
106  [1]=>
107  string(5) "world"
108  [2]=>
109  string(5) "HELLO"
110  [3]=>
111  string(5) "HELLO"
112  [4]=>
113  string(5) "HELLO"
114}
115array(5) {
116  [0]=>
117  string(5) "HELLO"
118  [1]=>
119  string(5) "HELLO"
120  [2]=>
121  string(5) "HELLO"
122  [3]=>
123  string(5) "hello"
124  [4]=>
125  string(5) "world"
126}
127Done
128