← All built-ins / shuffle()
shuffle()
shuffle(...$args): bool
Parameters
| Name | Type | Description |
|---|---|---|
| $a | array | array (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