The Ds\Sequence::last() function is an inbuilt function in PHP which is used to return the last element from the sequence.
Syntax:
mixed abstract public Ds\Sequence::last( void )
Parameters: This function does not accept any parameters.
Return value: This function returns the last element from the sequence.
Below programs illustrate the Ds\Sequence::last() function in PHP:
Program 1:
<?php // Create new sequence $seq = new \Ds\Vector([10, 20, 13, 25]); // Display the last element from the sequence var_dump($seq->last()); // Create new sequence $seq = new \Ds\Vector(['G', 'e', 'e', 'k', 's']); // Display the last element from the sequence var_dump($seq->last()); ?> |
Output:
int(25) string(1) "s"
Program 2:
<?php // Create new sequence $seq = new \Ds\Vector([21, 23, "p", "x"]); // Display the last element // from the sequence var_dump($seq->last()); // Function to push an element $seq->insert(4, "G"); // Display the last element // from the sequence var_dump($seq->last()); ?> |
Output:
string(1) "x" string(1) "G"
Reference: http://php.net/manual/en/ds-sequence.last.php
Recommended Posts:
- Last-child and last-of-type selector in SASS
- PHP | Ds\Map last() Function
- PHP | Ds\Vector last() Function
- PHP | Ds\Set 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.

