The Srand () function sows the random number generator seed, and the Array_rand () function randomly selects one or more elements from the array and returns. The second parameter is used to determine the number of elements to select. If more than one element is selected, the array containing the random key name is returned, otherwise the key name of the element is returned.
The Array_rand () function is useful when you want to remove one or more random cells from an array. It accepts input as an input array and an optional parameter, Num_req, indicating how many units you want to remove-if not specified, the default is 1. If you only take one, Array_rand () returns the key name of a random cell, or returns an array containing the random key name. This allows you to randomly remove the key names and values from the array.
<? PHP Srand (floatmicrotime() * 10000000); $input Array ("Hello", "World", "good", "Morning", "thank"); $rand _keys Array_rand ($input, 2); Print $input [$rand _keys[0]]. "\ n"; Print $input [$rand _keys[1]]. "\ n";? >
PHP randomly gets the values inside the array