The shuffle() function is used to randomize the order of the elements in the array. The function assigns new keys to the elements in array.
Note: The function uses a pseudo-random number generator that is not suitable for cryptographic purposes.
Returns TRUE on success or FALSE on failure
Parameter | Description |
---|---|
array | Required. Specifies the array to use |
Syntax
shuffle(array)
Example
$people = array("James","Lachlan","Cooper");
shuffle($people);
print_r($people);
Output
Array ( [0] => Cooper [1] => Lachlan [2] => James )