shuffle.php
Table of Contents
Functions
- shuffle() : array<string|int, mixed>
- Shuffles the elements of an array in place using the Fisher-Yates algorithm.
Functions
shuffle()
Shuffles the elements of an array in place using the Fisher-Yates algorithm.
shuffle(array<string|int, mixed> &$ar) : array<string|int, mixed>
This function randomizes the order of the elements in the given array. It operates directly on the passed array (by reference) and also returns it. The algorithm used ensures an unbiased shuffle.
If the array has 0 or 1 element, it is returned as is without changes.
Parameters
- $ar : array<string|int, mixed>
-
The array to shuffle (passed by reference).
Tags
Return values
array<string|int, mixed> —The shuffled array.