1--TEST-- 2Test shuffle() function : usage variation - arrays with diff types of values 3--FILE-- 4<?php 5/* 6* Test behaviour of shuffle() function when arrays having different 7* types of values, are passed to 'array_arg' argument 8*/ 9 10echo "*** Testing shuffle() : arrays with diff types of values ***\n"; 11 12// initialise different arrays 13$array_arg = array( 14 // array with positive int values 15/*1*/ array(0, 1, 2, 2147483647 ), 16 17 // array with negative int values 18 array(-1, -2, -2147483647 ), 19 20 // array with positive float values 21/*3*/ array(0.23, 1.34, 0e2, 200e-2, 30e2, 10e0, 2147473648.90), 22 23 // array with negative float values 24 array(-0.23, -1.34, -200e-2, -30e2, -10e0, -2147473649.80), 25 26 // array with single quoted and double quoted strings 27/*5*/ array('one', "123numbers", 'hello\tworld', "hello world\0", '12.34floatnum'), 28 29 // array with bool values 30 array(true, TRUE, FALSE, false), 31 32 // array with positive hexa values 33/*7*/ array(0x123, 0xabc, 0xABC, 0xac, 0xAb1, 0x9fa), 34 35 // array with negative hexa values 36 array(-0x123, -0xabc, -0xABC, -0xAb1, -0x9fa), 37 38 // array with positive octal values 39/*9*/ array(0123, 0234, 034, 00), 40 41 // array with negative octal values 42/*10*/ array(-0123, -0234, -034), 43 44); 45 46// looping to test shuffle() with each sub-array in the $array_arg array 47echo "\n*** Testing shuffle() with arrays having different types of values ***\n"; 48$counter = 1; 49foreach($array_arg as $arr) { 50 echo "\n-- Iteration $counter --\n"; 51 var_dump( shuffle($arr) ); 52 echo "\nThe output array is:\n"; 53 var_dump( $arr ); 54 $counter++; 55} 56 57echo "Done"; 58?> 59--EXPECTF-- 60*** Testing shuffle() : arrays with diff types of values *** 61 62*** Testing shuffle() with arrays having different types of values *** 63 64-- Iteration 1 -- 65bool(true) 66 67The output array is: 68array(4) { 69 [0]=> 70 int(%d) 71 [1]=> 72 int(%d) 73 [2]=> 74 int(%d) 75 [3]=> 76 int(%d) 77} 78 79-- Iteration 2 -- 80bool(true) 81 82The output array is: 83array(3) { 84 [0]=> 85 int(-%d) 86 [1]=> 87 int(-%d) 88 [2]=> 89 int(-%d) 90} 91 92-- Iteration 3 -- 93bool(true) 94 95The output array is: 96array(7) { 97 [0]=> 98 float(%f) 99 [1]=> 100 float(%f) 101 [2]=> 102 float(%f) 103 [3]=> 104 float(%f) 105 [4]=> 106 float(%f) 107 [5]=> 108 float(%f) 109 [6]=> 110 float(%f) 111} 112 113-- Iteration 4 -- 114bool(true) 115 116The output array is: 117array(6) { 118 [0]=> 119 float(-%f) 120 [1]=> 121 float(-%f) 122 [2]=> 123 float(-%f) 124 [3]=> 125 float(-%f) 126 [4]=> 127 float(-%f) 128 [5]=> 129 float(-%f) 130} 131 132-- Iteration 5 -- 133bool(true) 134 135The output array is: 136array(5) { 137 [0]=> 138 string(%d) "%s" 139 [1]=> 140 string(%d) "%s" 141 [2]=> 142 string(%d) "%s" 143 [3]=> 144 string(%d) "%s" 145 [4]=> 146 string(%d) "%s" 147} 148 149-- Iteration 6 -- 150bool(true) 151 152The output array is: 153array(4) { 154 [0]=> 155 bool(%s) 156 [1]=> 157 bool(%s) 158 [2]=> 159 bool(%s) 160 [3]=> 161 bool(%s) 162} 163 164-- Iteration 7 -- 165bool(true) 166 167The output array is: 168array(6) { 169 [0]=> 170 int(%d) 171 [1]=> 172 int(%d) 173 [2]=> 174 int(%d) 175 [3]=> 176 int(%d) 177 [4]=> 178 int(%d) 179 [5]=> 180 int(%d) 181} 182 183-- Iteration 8 -- 184bool(true) 185 186The output array is: 187array(5) { 188 [0]=> 189 int(-%d) 190 [1]=> 191 int(-%d) 192 [2]=> 193 int(-%d) 194 [3]=> 195 int(-%d) 196 [4]=> 197 int(-%d) 198} 199 200-- Iteration 9 -- 201bool(true) 202 203The output array is: 204array(4) { 205 [0]=> 206 int(%d) 207 [1]=> 208 int(%d) 209 [2]=> 210 int(%d) 211 [3]=> 212 int(%d) 213} 214 215-- Iteration 10 -- 216bool(true) 217 218The output array is: 219array(3) { 220 [0]=> 221 int(-%d) 222 [1]=> 223 int(-%d) 224 [2]=> 225 int(-%d) 226} 227Done 228