← All built-ins / shuffle()

shuffle()

shuffle(...$args): bool

Parameters

NameTypeDescription
$aarrayarray (by reference)

Return value

true; the elements are reordered randomly (not crypto-secure).

Example

$a = [1, 2, 3, 4, 5];
shuffle($a);
echo count($a) == 5 && array_sum($a) == 15 ? "ok" : "bad";
ok

See also

str_shuffle()rand()sort()