1--TEST--
2Test array_rand() function : basic functionality - array with default keys
3--FILE--
4<?php
5/* Prototype  : mixed array_rand(array $input [, int $num_req])
6 * Description: Return key/keys for random entry/entries in the array
7 * Source code: ext/standard/array.c
8*/
9
10/*
11 * Test array_rand() when array with default keys is passed to 'input' argument
12*/
13
14echo "*** Testing array_rand() : array with default keys ***\n";
15
16
17// Initialise the 'input' and 'num_req' variables
18$input = array(10, 20, 30, 40, 50, 60, 70);
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() : array with default keys ***
33
34-- with all default and optional arguments --
35array(%d) {
36  [0]=>
37  int(%d)
38  [1]=>
39  int(%d)
40  [2]=>
41  int(%d)
42  [3]=>
43  int(%d)
44  [4]=>
45  int(%d)
46  [5]=>
47  int(%d)
48}
49
50-- with default argument --
51int(%d)
52Done
53
54