The Ds\Deque::shift() function is an inbuilt function in PHP which is used to remove and return the first value of deque.
Syntax:
mixed Ds\Deque::shift( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the first value of deque which was removed.
Below programs illustrate the Ds\Deque::shift() function in PHP:
Program 1:
<?php // Declare a deque $deq = new \Ds\Deque([10, 20, 30, 40, 50, 60]); // Use Ds\Deque::shift() function var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); ?> |
int(10) int(20) int(30) int(40) int(50) int(60)
Program 2:
<?php // Declare a deque $deq = new \Ds\Deque(["geeks", "for", "geeks"]); // Use Ds\Deque::shift() function var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); // Declare a deque $deq = new \Ds\Deque(['G', 'E', 'E', 'K', 'S', 1, 2, 3]); // Use Ds\Deque::shift() function var_dump($deq -> shift()); var_dump($deq -> shift()); var_dump($deq -> shift()); ?> |
string(5) "geeks" string(3) "for" string(5) "geeks" string(1) "G" string(1) "E" string(1) "E"
Reference: https://www.php.net/manual/en/ds-deque.shift.php
Recommended Posts:
- PHP | Ds\Sequence shift() Function
- PHP | Ds\Vector shift() Function
- PHP | SplDoublyLinkedList shift() Function
- Node.js | shift() function
- JavaScript Array shift() Method
- How to Shift Inline Elements When Text Bold on Hover using CSS ?
- Delete the first element of array without using shift() method in JavaScript
- TypeScript | Array shift() Method
- Vue.js v-on:click.shift Directive
- JavaScript Unsigned Right Shift Assignment Operator
- Collect.js shift() Method
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() 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.

