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