Name
array_rand
Synopsis
mixed array_rand(arrayarray
[, intcount
])
Picks a random element from the given array. The second, optional, parameter can be given to specify a number of elements to pick and return. If more than one element is returned, an array of keys is returned, rather than the element’s value.
Before you call array_rand( )
, be sure to seed the
random-number generator using srand( )
.
Get Programming PHP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.