php shuffle() function


  Translation results:

英[ˈʃʌfl] 美[ˈʃʌfəl]

vt.Shuffle; shuffle; move; put aside, put aside

vi.shirk; shuffle; jump shuffle Dance; move

n.Shuffle, chaos, confusion; dragging feet

Third person singular: shuffles Plural: shuffles Present participle: shuffling Past tense: shuffled Past participle: shuffled

php shuffle() functionsyntax

Function: Reorder the elements in the array in random order:

Syntax: shuffle(array)

Parameters:

ParametersDescription
arrayRequired . Specifies the array to use.

Description: Returns TRUE if successful, returns FALSE if failed.

php shuffle() functionexample

<?php
$a = array("class" => "php中文网","name" => "西门","job" => "讲师");
shuffle($a);
print_r($a);
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [0] => 西门 [1] => php中文网 [2] => 讲师 )
<?php
$my_array = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow","e"=>"purple");

shuffle($my_array);
print_r($my_array);
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [0] => yellow [1] => green [2] => red [3] => purple [4] => blue )

Home

Videos

Q&A