September 2001
Intermediate to advanced
768 pages
32h 45m
English
mixed array_rand(array array, [int num_elements])
| array | Array from which to pick random elements |
| num_elements | Number of elements to pick at random |
Returns one or more keys at random from an array.
Returns:
Key or array of keys of random elements of an array; NULL on failure
Description:
This function selects num_elements elements at random from the array given by array and returns their keys as elements in a new array. If num_elements is 1 or omitted, a single key is returned. Otherwise, an indexed array is returned; the selected keys are the element values in the returned array.
Since array_rand() internally uses the rand() function, you should use srand() before calling array_rand() to ensure the greatest possible randomness. ...
Read now
Unlock full access