PHP | Ds\Map last() Function Last Updated : 21 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Map::last() function in PHP is used to find and get the last key-value pair from a Map object. If the map is empty then this function throws an exception. Syntax: Ds\Pair public Ds\Map::last ( void ) ParameterDs\Pair: It does not accepts any parameter. Return value: This function returns the last key-value pair from the Map object. If the Map object is empty then this function raises UnderflowException. Below program illustrate the Ds\Map::last() function in PHP: Program 1: php <?php // PHP program to illustrate the last() // function of Ds\map // Creating a Map $map = new \Ds\Map(["1" => "Geeks", "2" => "for", "3" => "Geeks"]); // Print last key-value pair print_r($map->last()); ?> Output: Ds\Pair Object ( [key] => 3 [value] => Geeks ) Program 2: php <?php // PHP program to illustrate the last() // function of Ds\map // Creating a Map $map = new \Ds\Map(["1" => "10", "2" => "20", "3" => 30]); // Print last key-value pair print_r($map->last()); ?> Output: Ds\Pair Object ( [key] => 3 [value] => 30 ) Reference: http://php.net/manual/en/ds-map.last.php Comment More infoAdvertise with us Next Article PHP | Ds\Map last() Function gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Similar Reads PHP | DsSet 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 | DsDeque last() Function The Ds\Deque::last() function is an inbuilt function in PHP which is used to return the last element of Deque if Deque is not empty. Syntax: public Ds\Deque::last( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the last element in the dequ 2 min read PHP | DsVector 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 | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 2 min read PHP | DsVector 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 | DsSequence 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 | DsSequence map() Function The Ds\Sequence::map() function is an inbuilt function in PHP which returns the result after applying callback function to each value. Syntax: Ds\Sequence abstract public Ds\Sequence::map( $callback ) Parameter: This function accepts single parameter $callback. The callback apply on each value of se 1 min read PHP DsSet 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 array_âkey_âlast() Function The array_âkey_âlast() function is an inbuilt function in PHP that is used to get the last key of an array. This function returns the last key without affecting the internal array pointer. Syntax: int|string|null array_âkey_âlast(array $array) Parameters: This function accepts single parameter $arra 1 min read PHP | DsDeque get() Function The Ds\Deque::get() function is an inbuilt function in PHP which is used to return the value at the given index. Syntax: public Ds\Deque::get( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index for which element is to be found. Return Value: This functio 2 min read Like