Annotation of embedaddon/php/ext/standard/tests/array/array_rand_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
14: echo "*** 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
22: echo"\n-- with all default and optional arguments --\n";
23: var_dump( array_rand($input,$num_req) );
24:
25: // Calling array_rand() with default arguments
26: echo"\n-- with default argument --\n";
27: var_dump( array_rand($input) );
28:
29: echo "Done";
30: ?>
31: --EXPECTF--
32: *** Testing array_rand() : array with default keys ***
33:
34: -- with all default and optional arguments --
35: array(%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 --
51: int(%d)
52: Done
53:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>