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