shuffle

(PHP 4, PHP 5, PHP 7)
Shuffle an array
bool shuffle ( array &$array )

This function shuffles (randomizes the order of the elements in) an array.

Parameters:
array

The array.

Returns:

Returns TRUE on success or FALSE on failure.

Notes:
This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned, rather than just reordering the keys.
Examples:
shuffle() example
<?php
$numbers = range(1, 20);
shuffle($numbers);
foreach ($numbers as $number) {
    echo "$number ";
}
?>

See also:

array_rand() -

comparison of array sorting functions -

doc_php
2016-02-24 16:12:57
Comments
Leave a Comment

Please login to continue.