first()

The first() method returns first value

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

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

//Gets first value
$arrayUtils->first();
// expected output: "Apple"

Syntax

$arrayUtils->first() : mixed;

Return value

  • A first value of array. If array is empty, returns NULL.

Prefixing

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

Last updated