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