1--TEST--
2Test array_rand() function : basic functionality - with associative array for 'input' argument
3--FILE--
4<?php
5/*
6 * Test array_rand() when associative array is passed to 'input' argument
7*/
8
9echo "*** Testing array_rand() : with associative array ***\n";
10
11
12// Initialise the 'input' and 'num_req' variables
13$input = array(
14  'one' => 1, 'two' => 2, 'three' => 3,
15  'FoUr' => 'four', '#5' => 5, 'SIX' => 'six',
16  "seven" => 7, "#8" => "eight", "nine" => "NINE"
17);
18
19$num_req = 6;
20
21// Calling array_rand() with optional argument
22echo"\n-- with all default and optional arguments --\n";
23var_dump( array_rand($input,$num_req) );
24
25// Calling array_rand() with default arguments
26echo"\n-- with default argument --\n";
27var_dump( array_rand($input) );
28
29echo "Done";
30?>
31--EXPECTF--
32*** Testing array_rand() : with associative array ***
33
34-- with all default and optional arguments --
35array(6) {
36  [0]=>
37  string(%d) "%s"
38  [1]=>
39  string(%d) "%s"
40  [2]=>
41  string(%d) "%s"
42  [3]=>
43  string(%d) "%s"
44  [4]=>
45  string(%d) "%s"
46  [5]=>
47  string(%d) "%s"
48}
49
50-- with default argument --
51string(%d) "%s"
52Done
53