PHP | Ds\Vector last() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Below programs illustrate the Ds\Vector::last() function in PHP: Program 1: PHP <?php // Create new vector $vector = new \Ds\Vector([1, 2, 3, 4, 5]); echo("Last element of vector: "); // Use last() function to find the // last element of vector var_dump($vector->last()); ?> Output: Last element of vector: int(5) Program 2: PHP <?php // Create new vector $vector = new \Ds\Vector(["geeks", "for", "geeks", "practice"]); // pop the vector element $vector->pop(); echo("Last element of vector: "); // Use last() function to find the // last element of vector var_dump($vector->last()); ?> Output: Last element of vector: string(5) "geeks" Reference: https://www.php.net/manual/en/ds-vector.last.php Comment More infoAdvertise with us Next Article PHP | Ds\Vector map() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP | Ds\Vector get() Function The Ds\Vector::get() function is an inbuilt function in PHP which is used to return the element at the given index. Syntax: mixed public Ds\Vector::get( $index ) Parameters: This function accepts a single parameter $index which contains the index (0-based indexing) at which the element is to be retu 1 min read PHP | Ds\Vector get() Function The Ds\Vector::get() function is an inbuilt function in PHP which is used to return the element at the given index. Syntax: mixed public Ds\Vector::get( $index ) Parameters: This function accepts a single parameter $index which contains the index (0-based indexing) at which the element is to be retu 1 min read PHP | Ds\Vector map() Function The Ds\Vector::map() function is an inbuilt function in PHP which is used to return the result of a callback after applying to each value in the vector. Syntax: Ds\Vector public Ds\Vector::map( $callback ) Parameters: This function accepts single parameter $callback which is to be applied to each ve 2 min read PHP | Ds\Vector map() Function The Ds\Vector::map() function is an inbuilt function in PHP which is used to return the result of a callback after applying to each value in the vector. Syntax: Ds\Vector public Ds\Vector::map( $callback ) Parameters: This function accepts single parameter $callback which is to be applied to each ve 2 min read 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: 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 ill 1 min read 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: 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 ill 1 min read Like