PHP | Ds\Set last() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 accept 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 // PHP program to illustrate the // Ds\set::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()); ?> Output: GfG Program 2: PHP <?php // PHP program to illustrate the // Ds\set::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()); ?> Output: 30 Reference: https://www.php.net/manual/en/ds-set.last.php Comment More infoAdvertise with us Next Article PHP | Ds\Sequence last() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP | Ds\Vector last() Function The Ds\Vector::last() function is an inbuilt function in PHP which is used to return the last element of the vector. Syntax: mixed public Ds\Vector::last( void ) Parameters: This function does not contain any parameter. Return Value: This function returns the value at the last index in the vector. B 1 min read PHP | Ds\Vector last() Function The Ds\Vector::last() function is an inbuilt function in PHP which is used to return the last element of the vector. Syntax: mixed public Ds\Vector::last( void ) Parameters: This function does not contain any parameter. Return Value: This function returns the value at the last index in the vector. B 1 min read PHP Ds\Set get() Function The Ds\Set::get() function of Ds\Set class in PHP is an inbuilt function which is used to get a value from the Set instance. This function is used to fetch a value present at a particular index in the Set instance. Syntax: mixed public Ds\Set::get ( int $index ) Parameters: This function accepts a s 2 min read PHP Ds\Set get() Function The Ds\Set::get() function of Ds\Set class in PHP is an inbuilt function which is used to get a value from the Set instance. This function is used to fetch a value present at a particular index in the Set instance. Syntax: mixed public Ds\Set::get ( int $index ) Parameters: This function accepts a s 2 min read PHP | Ds\Sequence last() Function 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 s 1 min read PHP | Ds\Sequence last() Function 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 s 1 min read Like