PHP | Ds\Map first() Function Last Updated : 20 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Map::first() function of PHP Ds\Map class is used to get the first key-value pair from the Map instance. Syntax: Ds\Pair public Ds\Map::first ( ) Parameters: This function does not accepts any parameter. Return value: It returns a pair of type Ds\Pair which is the first key-value pair from the Map instance. That is the key-value pair present at the front of the Map instance. Below programs illustrate the Ds\Map::first() function in PHP: Program 1: php <?php // PHP program to illustrate first() function $map = new \Ds\Map([1 => "Geeks", 2 => "for", 3 => "Geeks"]); print_r($map->first()); ?> Output: Ds\Pair Object ( [key] => 1 [value] => Geeks ) Program 2: php <?php // PHP program to illustrate first() function $map = new \Ds\Map(["first" => "Geeks", "second" => "for", "third" => "Geeks"]); print_r($map->first()); ?> Output: Ds\Pair Object ( [key] => first [value] => Geeks ) Reference: http://php.net/manual/en/ds-map.first.php Comment More infoAdvertise with us Next Article PHP | Ds\Map first() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Similar Reads PHP | DsSet first() Function The Ds\Set::first() function is an inbuilt function in PHP which returns the first element of the Set. Syntax: void public Ds\Set::first( void ) Parameter: This function does not accept any parameter. Return value: This function returns the first value of the Set. Below programs illustrate the Ds\Se 1 min read PHP | DsDeque first() Function The Ds\Deque::first() function is an inbuilt function in PHP which returns the first value in the Deque if Deque is not empty. Syntax: public Ds\Deque::first( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the first element from the Deque, 2 min read PHP | DsVector first() Function The Ds\Vector::first() function is an inbuilt function in PHP which is used to find the first element in the vector. Syntax: mixed public Ds\Vector::first( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the first element present in the vector. Bel 1 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 | 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 Like