2 /* Prototype : mixed array_rand(array $input [, int $num_req])
3 * Description: Return key/keys for random entry/entries in the array
4 * Source code: ext/standard/array.c
8 * Test array_rand() when associative array is passed to 'input' argument
10 <<__EntryPoint
>> function main(): void
{
11 echo "*** Testing array_rand() : with associative array ***\n";
14 // Initialise the 'input' and 'num_req' variables
16 'one' => 1, 'two' => 2, 'three' => 3,
17 'FoUr' => 'four', '#5' => 5, 'SIX' => 'six',
18 "seven" => 7, "#8" => "eight", "nine" => "NINE"
23 // Calling array_rand() with optional argument
24 echo"\n-- with all default and optional arguments --\n";
25 var_dump( array_rand($input,$num_req) );
27 // Calling array_rand() with default arguments
28 echo"\n-- with default argument --\n";
29 var_dump( array_rand($input) );