PHP | Ds\Map first() Function
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 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 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
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP | max( ) Function
- PHP Ds\Map sum() Function
- PHP | min( ) Function
- PHP | pi( ) Function
- PHP | next() Function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- PHP | abs() Function
- PHP | sin( ) Function
- PHP | exp() Function
- PHP | tan( ) Function
- PHP | cos( ) Function
- PHP | pow( ) Function
- PHP | each() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



