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