Array_rand () randomly removes one or more units from the array [function] This function returns the specified number of array elements in an array. If only one function is retrieved, the key name of a random unit will be returned. Otherwise, an array containing a random key name will be returned so that random access from... SyntaxHighlighter. all () can be obtained ();
Array_rand () randomly retrieves one or more units from the array.
[Function]
This function returns the specified number of array elements in an array.
If only one function is retrieved, the key name of a random unit is returned. Otherwise, an array containing a random key name is returned.
In this way, the keys and values can be randomly retrieved from the array.
Scope of use]
Php4, php5.
[Use]
Mixed array_rand (array input [. int num_req])
The return value is a hybrid array, and the input parameter is the original array to be retrieved.
The optional parameter num_req indicates the number of elements to be retrieved.
[Example]
[Php]
Srand (float) microtime () * 10000000 );
$ Input = array ("Neo", "Morpheus", "Trinity", "Cypher", "");
Var_dump (array_rand ($ input, 2 ));
/*
Array (2 ){
[0] =>
Int (0)
[1] =>
Int (4)
}
*/
Taken from zuodefeng's note