PHP | Ds\Set last() Function
The Ds\Set::last() function is an inbuilt function in PHP which is used to return the last element from the Set instance.
Syntax:
public Ds\Set::last( void ) : 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:
- PHP | cos( ) Function
- PHP | tan( ) Function
- PHP | key() Function
- PHP | each() Function
- PHP | next() Function
- PHP Ds\Map sum() Function
- PHP | sin( ) Function
- PHP | pi( ) Function
- PHP | min( ) Function
- PHP | max( ) Function
- PHP Ds\Map first() Function
- PHP | ord() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Set first() Function
- CSS | var() Function
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.



