Home Menu

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] => 14
    [1] => 5
    [2] => 7
    [3] => 20
    [4] => 10
    [5] => 12
    [6] => 4
    [7] => 19
    [8] => 9
    [9] => 3
    [10] => 6
    [11] => 16
    [12] => 13
    [13] => 2
    [14] => 1
    [15] => 18
    [16] => 8
    [17] => 11
    [18] => 15
    [19] => 17
)

Return

<?

$array = range(1, 20);

$return = shuffle($array);

var_export($return);

?>
true

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms