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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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));
  
?>

chevron_right


Output:

Ds\Pair Object
(
    [key] => 4
    [value] => 40
)

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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));
  
?>

chevron_right


Output:

Ds\Pair Object
(
    [key] => second
    [value] => for
)

Reference: http://php.net/manual/en/ds-map.skip.php



My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.