Returns one or a specified number of items randomly from the array.

/**
 * Returns one or a specified number of items randomly from the array.
 *
 * @param int|null $number Number of items to return.
 */
public function random(?int $number = null)

Examples

$result = Arrays::create(['foo', 'bar', 'baz'])->random();

Getting Started

Methods