PHP | Ds\skip() Function
The skip() function of PHP Ds\Map class is used to get a key-value pair present at a specific index in the Map instance. The index is passed as a parameter to the function and the function returns the Pair present at that index in the map.
Note: The index passed in the parameter is 0-based. That is the elements starts from the index 0.
Syntax:
public Ds\Map::skip(int $index)
Parameters: This function accepts a single parameter $index which is the index from which the key-value pair is needed to be returned.
Return Value: The function returns a pair of type Ds\Pair which is the key-value pair in the Map instance present at the index specified by the parameter $index.
Below programs illustrate the skip() function:
Program 1:
<?php // PHP program to illustrate skip() function $map = new \Ds\Map([1 => 10, 2 => 20, 3 => 30, 4 => 40, 5 => 50, 6 => 60]); // Key-Value pair present at index 3 print_r($map->skip(3)); ?> |
Output:
Ds\Pair Object
(
[key] => 4
[value] => 40
)
Program 2:
<?php // PHP program to illustrate skip() function $map = new \Ds\Map(["first" => "Geeks", "second" => "for", "third" => "Geeks"]); // Key-Value pair present at index 1 print_r($map->skip(1)); ?> |
Output:
Ds\Pair Object
(
[key] => second
[value] => for
)
Reference: http://php.net/manual/en/ds-map.skip.php
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP | Ds\Set xor() Function
- PHP | pi( ) Function
- PHP | pow( ) Function
- PHP | each() Function
- PHP | Ds\Map put() Function
- PHP | Ds\Map xor() Function
- PHP Ds\Set sum() Function
- PHP Ds\Set get() Function
- PHP | key() Function
- PHP | end() Function
- PHP | min( ) Function
- PHP | max( ) Function
- PHP | exp() Function
- PHP Ds\Map sum() 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.



