PHP | Ds\Map last() Function Read Courses Improve Improve Improve Like Article Like Save Article Save Report issue 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 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 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 Last Updated : 21 Aug, 2019 Like Article Save Article Previous PHP | Ds\Map merge() Function Next PHP | GmagickDraw setstrokecolor() Function Share your thoughts in the comments Add Your Comment Please Login to comment...