You are viewing documentation for an outdated version. It is no longer supported!
Array
Extended version of Laravel's Arr
component.
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::random
.
Seed
You can also provide a seed for the random number generator.
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.