Definition :
The shuffle() Function is a builtin function in PHP and is used to shuffle or randomize the order of the elements in an array. This function assigns new keys for the elements in the array. It will also remove any existing keys, rather than just reordering the keys and assigns numeric keys starting from zero.
shuffle(array)
The shuffle()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to work on. |
Example1 : Given Below example randomrized the order of an array
Output : (refresh,then show random order of array)
Array
(
[0] => Designing
[1] => Web
[2] => House
)
Example2 : Shuffle with Associative Array
Output : (refresh,then show random order of array)
Array
(
[0] => House
[1] => Designing
[2] => Web
)