1--TEST-- 2Test array_reverse() function : usage variations - two dimensional arrays for 'array' argument 3--FILE-- 4<?php 5/* 6 * testing the functionality of array_reverse() by giving 2-D arrays for $array argument 7*/ 8 9echo "*** Testing array_reverse() : usage variations ***\n"; 10 11// Initializing the 2-d arrays 12$two_dimensional_array = array( 13 14 // associative array 15 array('color' => 'red', 'item' => 'pen', 'place' => 'LA'), 16 17 // numeric array 18 array(1, 2, 3, 4, 5), 19 20 // combination of numeric and associative arrays 21 array('a' => 'green', 'red', 'brown', 33, 88, 'orange', 'item' => 'ball') 22); 23 24// calling array_reverse() with various types of 2-d arrays 25// with default arguments 26echo "-- with default argument --\n"; 27var_dump( array_reverse($two_dimensional_array) ); // whole array 28var_dump( array_reverse($two_dimensional_array[1]) ); // sub array 29 30// with $preserve_keys argument 31echo "-- with all possible arguments --\n"; 32// whole array 33var_dump( array_reverse($two_dimensional_array, true) ); 34var_dump( array_reverse($two_dimensional_array, false) ); 35// sub array 36var_dump( array_reverse($two_dimensional_array[1], true) ); 37var_dump( array_reverse($two_dimensional_array[1], false) ); 38 39echo "Done"; 40?> 41--EXPECT-- 42*** Testing array_reverse() : usage variations *** 43-- with default argument -- 44array(3) { 45 [0]=> 46 array(7) { 47 ["a"]=> 48 string(5) "green" 49 [0]=> 50 string(3) "red" 51 [1]=> 52 string(5) "brown" 53 [2]=> 54 int(33) 55 [3]=> 56 int(88) 57 [4]=> 58 string(6) "orange" 59 ["item"]=> 60 string(4) "ball" 61 } 62 [1]=> 63 array(5) { 64 [0]=> 65 int(1) 66 [1]=> 67 int(2) 68 [2]=> 69 int(3) 70 [3]=> 71 int(4) 72 [4]=> 73 int(5) 74 } 75 [2]=> 76 array(3) { 77 ["color"]=> 78 string(3) "red" 79 ["item"]=> 80 string(3) "pen" 81 ["place"]=> 82 string(2) "LA" 83 } 84} 85array(5) { 86 [0]=> 87 int(5) 88 [1]=> 89 int(4) 90 [2]=> 91 int(3) 92 [3]=> 93 int(2) 94 [4]=> 95 int(1) 96} 97-- with all possible arguments -- 98array(3) { 99 [2]=> 100 array(7) { 101 ["a"]=> 102 string(5) "green" 103 [0]=> 104 string(3) "red" 105 [1]=> 106 string(5) "brown" 107 [2]=> 108 int(33) 109 [3]=> 110 int(88) 111 [4]=> 112 string(6) "orange" 113 ["item"]=> 114 string(4) "ball" 115 } 116 [1]=> 117 array(5) { 118 [0]=> 119 int(1) 120 [1]=> 121 int(2) 122 [2]=> 123 int(3) 124 [3]=> 125 int(4) 126 [4]=> 127 int(5) 128 } 129 [0]=> 130 array(3) { 131 ["color"]=> 132 string(3) "red" 133 ["item"]=> 134 string(3) "pen" 135 ["place"]=> 136 string(2) "LA" 137 } 138} 139array(3) { 140 [0]=> 141 array(7) { 142 ["a"]=> 143 string(5) "green" 144 [0]=> 145 string(3) "red" 146 [1]=> 147 string(5) "brown" 148 [2]=> 149 int(33) 150 [3]=> 151 int(88) 152 [4]=> 153 string(6) "orange" 154 ["item"]=> 155 string(4) "ball" 156 } 157 [1]=> 158 array(5) { 159 [0]=> 160 int(1) 161 [1]=> 162 int(2) 163 [2]=> 164 int(3) 165 [3]=> 166 int(4) 167 [4]=> 168 int(5) 169 } 170 [2]=> 171 array(3) { 172 ["color"]=> 173 string(3) "red" 174 ["item"]=> 175 string(3) "pen" 176 ["place"]=> 177 string(2) "LA" 178 } 179} 180array(5) { 181 [4]=> 182 int(5) 183 [3]=> 184 int(4) 185 [2]=> 186 int(3) 187 [1]=> 188 int(2) 189 [0]=> 190 int(1) 191} 192array(5) { 193 [0]=> 194 int(5) 195 [1]=> 196 int(4) 197 [2]=> 198 int(3) 199 [3]=> 200 int(2) 201 [4]=> 202 int(1) 203} 204Done 205