You are viewing documentation for an outdated version. It is no longer supported!

Array

Extended version of Laravel's Arr componentopen in new window.

randomElement()

Returns a single random element from a given list.

use Aedart\Utils\Arr;

$element = Arr::randomElement(['Jim', 'Sine', 'Ally', 'Gordon']);

See also Laravel's Arr::randomopen in new window.

Seed

You can also provide a seed for the random number generatoropen in new window.

use Aedart\Utils\Arr;
use Aedart\Utils\Math;

$element = Arr::randomElement(['Jim', 'Sine', 'Ally', 'Gordon'], Math::seed());

See Math::seed() for additional information about seeding.