(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
1 2 3 4 5 6 7 | <?php $numbers = range(1, 20); shuffle( $numbers ); foreach ( $numbers as $number ) { echo "$number " ; } ?> |
See also:
Please login to continue.