shuffle

Shuffle an array

Syntax

shuffle ( array &$array ) : bool

Parameters

array

The array.

Return

Returns TRUE on success or FALSE on failure.

Examples

array

<?

$array = range(1, 20);

shuffle($array);

print_r($array);

?>
Array
(
    [0] => 19
    [1] => 11
    [2] => 1
    [3] => 12
    [4] => 17
    [5] => 8
    [6] => 14
    [7] => 7
    [8] => 13
    [9] => 15
    [10] => 10
    [11] => 2
    [12] => 20
    [13] => 4
    [14] => 3
    [15] => 16
    [16] => 18
    [17] => 9
    [18] => 5
    [19] => 6
)

Return

<?

$array = range(1, 20);

$return = shuffle($array);

var_export($return);

?>
true

PHP

Home Menu