1--TEST-- 2Test shuffle() function : usage variation - with MultiDimensional array 3--FILE-- 4<?php 5/* 6* Test behaviour of shuffle() function when multi-dimensional array is 7* passed to 'array_arg' argument 8*/ 9 10echo "*** Testing shuffle() : with multi-dimensional array ***\n"; 11 12// initialise the multi-dimensional array 13$array_arg = array( 14 array(1, 2, 3), 15 array(4, 5, 6), 16 array(7, 8, 9), 17 array(10000, 20000000, 30000000), 18 array(0, 0, 0), 19 array(012, 023, 034), 20 array(0x1, 0x0, 0xa) 21 22); 23 24// calling shuffle() function with multi-dimensional array 25var_dump( shuffle($array_arg) ); 26echo "\nThe output array is:\n"; 27var_dump( $array_arg ); 28 29 30// looping to test shuffle() with each sub-array in the multi-dimensional array 31echo "\n*** Testing shuffle() with arrays having different types of values ***\n"; 32$counter = 1; 33for($i=0; $i<=6; $i++) { 34 echo "\n-- Iteration $counter --\n"; 35 var_dump( shuffle($array_arg[$i]) ); 36 echo "\nThe output array is:\n"; 37 var_dump( $array_arg[$i] ); 38 $counter++; 39} 40 41echo "Done"; 42?> 43--EXPECTF-- 44*** Testing shuffle() : with multi-dimensional array *** 45bool(true) 46 47The output array is: 48array(7) { 49 [0]=> 50 array(3) { 51 [0]=> 52 int(%d) 53 [1]=> 54 int(%d) 55 [2]=> 56 int(%d) 57 } 58 [1]=> 59 array(3) { 60 [0]=> 61 int(%d) 62 [1]=> 63 int(%d) 64 [2]=> 65 int(%d) 66 } 67 [2]=> 68 array(3) { 69 [0]=> 70 int(%d) 71 [1]=> 72 int(%d) 73 [2]=> 74 int(%d) 75 } 76 [3]=> 77 array(3) { 78 [0]=> 79 int(%d) 80 [1]=> 81 int(%d) 82 [2]=> 83 int(%d) 84 } 85 [4]=> 86 array(3) { 87 [0]=> 88 int(%d) 89 [1]=> 90 int(%d) 91 [2]=> 92 int(%d) 93 } 94 [5]=> 95 array(3) { 96 [0]=> 97 int(%d) 98 [1]=> 99 int(%d) 100 [2]=> 101 int(%d) 102 } 103 [6]=> 104 array(3) { 105 [0]=> 106 int(%d) 107 [1]=> 108 int(%d) 109 [2]=> 110 int(%d) 111 } 112} 113 114*** Testing shuffle() with arrays having different types of values *** 115 116-- Iteration 1 -- 117bool(true) 118 119The output array is: 120array(3) { 121 [0]=> 122 int(%d) 123 [1]=> 124 int(%d) 125 [2]=> 126 int(%d) 127} 128 129-- Iteration 2 -- 130bool(true) 131 132The output array is: 133array(3) { 134 [0]=> 135 int(%d) 136 [1]=> 137 int(%d) 138 [2]=> 139 int(%d) 140} 141 142-- Iteration 3 -- 143bool(true) 144 145The output array is: 146array(3) { 147 [0]=> 148 int(%d) 149 [1]=> 150 int(%d) 151 [2]=> 152 int(%d) 153} 154 155-- Iteration 4 -- 156bool(true) 157 158The output array is: 159array(3) { 160 [0]=> 161 int(%d) 162 [1]=> 163 int(%d) 164 [2]=> 165 int(%d) 166} 167 168-- Iteration 5 -- 169bool(true) 170 171The output array is: 172array(3) { 173 [0]=> 174 int(%d) 175 [1]=> 176 int(%d) 177 [2]=> 178 int(%d) 179} 180 181-- Iteration 6 -- 182bool(true) 183 184The output array is: 185array(3) { 186 [0]=> 187 int(%d) 188 [1]=> 189 int(%d) 190 [2]=> 191 int(%d) 192} 193 194-- Iteration 7 -- 195bool(true) 196 197The output array is: 198array(3) { 199 [0]=> 200 int(%d) 201 [1]=> 202 int(%d) 203 [2]=> 204 int(%d) 205} 206Done 207