PHP shuffle array function

Last Updated: February 21, 2022

shuffle – Shuffle an array

Syntax

 shuffle(array &$array): bool

Supports (PHP 4 , PHP 5, PHP 7, PHP 8)

Parameters

Parameter Description
array The array

Return Value

Returns true on success or false on failure.

Example

$array1 = array('a', 'c', 'b', 'D', 'E', 'F');

shuffle($array1);
print_r($array1);

Output

Array ( [0] => E [1] => b [2] => a [3] => D [4] => c [5] => F )

Test