random()

The random() method returns random value

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["Apple", "Banana", "Carrot"]);

//Gets random value
$arrayUtils->random();
// output is random, so always different

Syntax

$arrayUtils->random() : mixed;

Return value

  • A random value from array. If array is empty, returns NULL.

Prefixing

ArrayUtils::randomFrom(iterable $from) : mixed;

Last updated