The Ds\Set::last() function is an inbuilt function in PHP which is used to return the last element from the Set instance.
Syntax:
void public Ds\Set::last( void )
Parameter: This function does not accepts any parameter.
Return Value: This function returns the last value of the Set.
Below programs illustrate the Ds\Set::last() function in PHP:
Program 1:
<?php // PHP program to illustarte the // last() function // Create a set instance $set = new \Ds\Set(); // Adding elements to Set $set->add("Welcome"); $set->add("to"); $set->add("GfG"); // Print the last element from set print_r($set->last()); ?> |
chevron_right
filter_none
Output:
GfG
Program 2:
<?php // PHP program to illustarte the // last() function // Create a set instance $set = new \Ds\Set(); // Adding elements to Set $set->add("10"); $set->add("20"); $set->add("30"); // Print the last element from set print_r($set->last()); ?> |
chevron_right
filter_none
Output:
30
Reference: http://php.net/manual/en/ds-set.last.php
Recommended Posts:
- Last-child and last-of-type selector in SASS
- PHP | Ds\Sequence last() Function
- PHP | Ds\Map last() Function
- PHP | Ds\Vector last() Function
- PHP | Ds\Deque last() Function
- PHP program to find the length of the last word in string
- PHP | Print the last value of an array without affecting the pointer
- Determine the first and last iteration in a foreach loop in PHP?
- How to get the last n characters of a PHP string?
- How to get last day of a month from date in PHP ?
- jQuery | :last Selector
- Underscore.js | _.last() with Examples
- CSS | :last-child Selector
- CSS | :last-of-type Selector
- CSS | text-align-last Property
- CSS | :nth-last-child() Selector
- CSS | :nth-last-of-type() Selector
- jQuery | :last-of-type Selector
- jQuery | :nth-last-child() Selector
- jQuery | :last-child Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

