1--TEST--
2array_shuffle(): Test return type and value for expected input
3--FILE--
4<?php
5/*
6* Function is implemented in ext/standard/array.c
7*/
8$numbers = range(1, 20);
9echo "*** testing array_shuffle  \n";
10$a = array();
11var_dump(shuffle($a));
12var_dump($a);
13$a = array(1);
14var_dump(shuffle($a));
15var_dump($a);
16$a = array(2 => 1);
17var_dump(shuffle($a));
18var_dump($a);
19$a = array("a" => 1);
20var_dump(shuffle($a));
21var_dump($a);
22$a = array(array(1, 2, 3));
23var_dump(shuffle($a));
24var_dump($a);
25$a = array(1, 1, 1, 1);
26var_dump(shuffle($a));
27var_dump($a);
28$arr1 = array(5 => 1, 6 => 2, 7 => 3, 8 => 9);
29$arr2 = array(5 => 1, 6 => 2, 7 => 3, 8 => 9);
30shuffle($arr1);
31echo "this should be 0->...." . count(array_diff($arr1, $arr2)) . "\n";
32echo "this should be 4->...." . count(array_intersect($arr1, $arr2)) . "\n";
33$bigarray = range(1, 400);
34shuffle($bigarray);
35echo "this should be 400->...." . count($bigarray) . "\n";
36echo "*** testing pass by reference  \n";
37$original = $bigarray;
38shuffle($bigarray);
39$diffarray = array_diff_assoc($original, $bigarray);
40if (count($diffarray) < 350) {
41    // with 400 entries, the probability that 50 entries or more get the same
42    // key-> value association should be so close to zero it wont happen in the lifetime of the
43    // universe.
44    echo "shuffled array seems to be similar to original\n";
45    var_dump($original);
46    var_dump($bigarray);
47} else {
48    echo "test passed \n";
49}
50?>
51--EXPECT--
52*** testing array_shuffle
53bool(true)
54array(0) {
55}
56bool(true)
57array(1) {
58  [0]=>
59  int(1)
60}
61bool(true)
62array(1) {
63  [0]=>
64  int(1)
65}
66bool(true)
67array(1) {
68  [0]=>
69  int(1)
70}
71bool(true)
72array(1) {
73  [0]=>
74  array(3) {
75    [0]=>
76    int(1)
77    [1]=>
78    int(2)
79    [2]=>
80    int(3)
81  }
82}
83bool(true)
84array(4) {
85  [0]=>
86  int(1)
87  [1]=>
88  int(1)
89  [2]=>
90  int(1)
91  [3]=>
92  int(1)
93}
94this should be 0->....0
95this should be 4->....4
96this should be 400->....400
97*** testing pass by reference
98test passed
99