1--TEST-- 2array_rand() tests 3--FILE-- 4<?php 5 6var_dump(array_rand()); 7var_dump(array_rand(array())); 8var_dump(array_rand(array(), 0)); 9var_dump(array_rand(0, 0)); 10var_dump(array_rand(array(1,2,3), 0)); 11var_dump(array_rand(array(1,2,3), -1)); 12var_dump(array_rand(array(1,2,3), 10)); 13var_dump(array_rand(array(1,2,3), 3)); 14var_dump(array_rand(array(1,2,3), 2)); 15 16echo "Done\n"; 17?> 18--EXPECTF-- 19Warning: array_rand() expects at least 1 parameter, 0 given in %s on line %d 20NULL 21NULL 22 23Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d 24NULL 25 26Warning: array_rand() expects parameter 1 to be array, integer given in %s on line %d 27NULL 28 29Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d 30NULL 31 32Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d 33NULL 34 35Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d 36NULL 37array(3) { 38 [0]=> 39 int(%d) 40 [1]=> 41 int(%d) 42 [2]=> 43 int(%d) 44} 45array(2) { 46 [0]=> 47 int(%d) 48 [1]=> 49 int(%d) 50} 51Done 52