php8.5
Home/ Manual/ ds / set/ Ds\Set::last

Ds\Set::last

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Returns the last value in the set

Description

Ds\Set::last(): mixed

Returns the last value in the set.

Parameters Parameters

Return Values

The last value in the set.

Errors/Exceptions

UnderflowException if empty.

Examples

Ds\Set::last() example

php
<?php
$set = new \Ds\Set([1, 2, 3]);
var_dump($set->last());
?>

The above example will output something similar to:

output
int(3)

Source: reference/ds/ds/set/last.xml · from the official PHP manual (php/doc-en)