1--TEST-- 2Test rsort() function : usage variations - multi-dimensional arrays 3--FILE-- 4<?php 5/* 6 * Pass rsort() multi-dimensional arrays to test behaviour 7 */ 8 9echo "*** Testing rsort() : variation ***\n"; 10 11// array of arrays 12$various_arrays = array ( 13 // null array 14 array(), 15 16 // array contains null sub array 17 array( array() ), 18 19 // array of arrays along with some values 20 array(44, 11, array(64, 61) ), 21 22 // array containing sub arrays 23 array(array(33, -5, 6), array(11), array(22, -55), array() ) 24); 25 26 27$count = 1; 28 29// loop through to test rsort() with different arrays 30foreach ($various_arrays as $array) { 31 32 echo "\n-- Iteration $count --\n"; 33 34 echo "\n-- 'flag' value is default --\n"; 35 $temp_array = $array; 36 var_dump(rsort($temp_array) ); 37 var_dump($temp_array); 38 39 echo "\n-- 'flag' value is SORT_REGULAR --\n"; 40 $temp_array = $array; 41 var_dump(rsort($temp_array, SORT_REGULAR) ); 42 var_dump($temp_array); 43 $count++; 44} 45 46echo "Done"; 47?> 48--EXPECT-- 49*** Testing rsort() : variation *** 50 51-- Iteration 1 -- 52 53-- 'flag' value is default -- 54bool(true) 55array(0) { 56} 57 58-- 'flag' value is SORT_REGULAR -- 59bool(true) 60array(0) { 61} 62 63-- Iteration 2 -- 64 65-- 'flag' value is default -- 66bool(true) 67array(1) { 68 [0]=> 69 array(0) { 70 } 71} 72 73-- 'flag' value is SORT_REGULAR -- 74bool(true) 75array(1) { 76 [0]=> 77 array(0) { 78 } 79} 80 81-- Iteration 3 -- 82 83-- 'flag' value is default -- 84bool(true) 85array(3) { 86 [0]=> 87 array(2) { 88 [0]=> 89 int(64) 90 [1]=> 91 int(61) 92 } 93 [1]=> 94 int(44) 95 [2]=> 96 int(11) 97} 98 99-- 'flag' value is SORT_REGULAR -- 100bool(true) 101array(3) { 102 [0]=> 103 array(2) { 104 [0]=> 105 int(64) 106 [1]=> 107 int(61) 108 } 109 [1]=> 110 int(44) 111 [2]=> 112 int(11) 113} 114 115-- Iteration 4 -- 116 117-- 'flag' value is default -- 118bool(true) 119array(4) { 120 [0]=> 121 array(3) { 122 [0]=> 123 int(33) 124 [1]=> 125 int(-5) 126 [2]=> 127 int(6) 128 } 129 [1]=> 130 array(2) { 131 [0]=> 132 int(22) 133 [1]=> 134 int(-55) 135 } 136 [2]=> 137 array(1) { 138 [0]=> 139 int(11) 140 } 141 [3]=> 142 array(0) { 143 } 144} 145 146-- 'flag' value is SORT_REGULAR -- 147bool(true) 148array(4) { 149 [0]=> 150 array(3) { 151 [0]=> 152 int(33) 153 [1]=> 154 int(-5) 155 [2]=> 156 int(6) 157 } 158 [1]=> 159 array(2) { 160 [0]=> 161 int(22) 162 [1]=> 163 int(-55) 164 } 165 [2]=> 166 array(1) { 167 [0]=> 168 int(11) 169 } 170 [3]=> 171 array(0) { 172 } 173} 174Done 175