shuffle() function rearranges the elements in the array in random order.
If successful, return TRUE, otherwise return FALSE.
Note: This function assigns a new key name to the unit in the array. This will delete the original keys rather than just reorder them.
Note: As of PHP 4.2.0, it is no longer necessary to seed the random number generator with the srand() or mt_srand() function, it is now done automatically.
shuffle(array)
Parameters | Description |
---|---|
array | Required. Specifies the array to use. |
<?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); shuffle($my_array); print_r($my_array); ?>
Output:
Array ( [0] => Cat [1] => Horse [2] => Dog )
The above has introduced the PHP shuffle function, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.