Easy Tutorial
❮ Func Misc Pack Func Mysqli Free Result ❯

PHP shuffle() Function

Complete PHP Array Reference Manual

Example

Rearrange the elements of an array in random order:


Definition and Usage

The shuffle() function rearranges the elements of an array in random order.

This function assigns new keys to the elements in the array; existing keys will be removed (see Example 1 below).


Syntax

Parameter Description
array Required. Specifies the array to use.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 4+
--- ---
Changelog: Since PHP 4.2.0, the random number generator is seeded automatically.
--- ---

More Examples

Example 1

Rearrange the elements of an array in random order:


❮ Func Misc Pack Func Mysqli Free Result ❯