last()

The last() method returns last value

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

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

//Gets last value
$arrayUtils->last();
// expected output: "Carrot"

Syntax

$arrayUtils->last() : mixed;

Return value

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

Prefixing

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

Last updated