The Ds\Deque::slice() function is an inbuilt function in PHP which is used to return a sub-Deque which contains elements of the Deque within the index range.
public Ds\Deque::slice( $index, $length ) : Ds\Deque
Parameters: This function accept two parameters as mentioned above and described below:
- index: This parameter hold the starting index of sub Deque. The index value can be positive and negative. If the index value is positive then it starts at the index of Deque and if the index value is negative then Deque starts from ends.
- length: This parameter holds the length of sub Deque. This parameter can take positive and negative values. If length is positive then sub-Deque size is equal to a given length and if the length is negative then Deque will stop that many values from the ends.
Return Value: This function returns a sub-Deque with sliced elements from the Deque of given range.
Below programs illustrate the Ds\Deque::slice() function in PHP:
Elements of Deque Ds\Deque Object (  => 1  => 2  => 3  => 4  => 5  => 6 ) Deque after slicing: Ds\Deque Object (  => 3  => 4  => 5  => 6 )
Elements of Deque Ds\Deque Object (  => 1  => 2  => 3  => 4  => 5  => 6 ) Deque after slicing: Ds\Deque Object (  => 4 )
- PHP Ds\Map slice() Function
- PHP | Ds\Set slice() Function
- Node.js | slice() function
- PHP | Ds\Vector slice() Function
- PHP | Ds\Sequence slice() Function
- CSS | border-image-slice Property
- How to get the function name inside a function in PHP ?
- p5.js | cos() function
- PHP | pos() Function
- PHP | pow( ) Function
- PHP | Ds\Set first() Function
- PHP | key() 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 email@example.com. 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.