<?php
$map = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5]);
// Slice from 2 onwards
print_r($map->slice(2)->toArray());
// Slice from 1, for a length of 3
print_r($map->slice(1, 3)->toArray());
// Slice from 1 onwards
print_r($map->slice(1)->toArray());
// Slice from 2 from the end onwards
print_r($map->slice(-2)->toArray());
// Slice from 1 to 1 from the end
print_r($map->slice(1, -1)->toArray());
?>
The above example will output
something similar to:
Array
(
[c] => 3
[d] => 4
[e] => 5
)
Array
(
[b] => 2
[c] => 3
[d] => 4
)
Array
(
[b] => 2
[c] => 3
[d] => 4
[e] => 5
)
Array
(
[d] => 4
[e] => 5
)
Array
(
[b] => 2
[c] => 3
[d] => 4
)