PHP | Ds\Sequence shift() Function Last Updated : 22 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Sequence::shift() function is an inbuilt function in PHP which is used to removes the first element from the sequence and return it. Syntax: mixed abstract public Ds\Sequence::shift ( void ) Parameters: This function does not accepts any parameter. Return values: This function returns the first value which is removed from the sequence. Below programs illustrate the Ds\Sequence::shift() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector([9, 10, 15, 20]); // Use shift() function to remove // first element from sequence var_dump($seq->shift()); var_dump($seq->shift()); var_dump($seq->shift()); var_dump($seq->shift()); ?> Output: int(9) int(10) int(15) int(20) Program 2: php <?php // Create new sequence $seq = new \Ds\Vector(["Geeks", "for", "Geeks"]); // Use shift() function to remove // first element from sequence var_dump($seq->shift()); var_dump($seq->shift()); var_dump($seq->shift()); ?> Output: string(5) "Geeks" string(3) "for" string(5) "Geeks" Reference: http://php.net/manual/en/ds-sequence.shift.php Comment More infoAdvertise with us Next Article PHP | DsSequence unshift() Function V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Similar Reads PHP | DsDeque unshift() Function The Ds\Deque::unshift() function is an inbuilt function in PHP which is used to add the value in front of the deque. Syntax: void Ds\Deque::unshift( $values ) Parameters: This function accepts single parameter $values which holds the values to add in the front of the deque. Return Value: This functi 2 min read PHP | DsVector unshift() Function The Ds\Vector::unshift() function is an inbuilt function in PHP which is used to adds elements to the front of vector. This function moves all the elements in the vector towards forward and adds the new element to the front. Syntax: void public Ds\Vector::unshift( $values ) Parameters: This function 2 min read PHP | DsSequence unshift() Function The Ds\Sequence::unshift() function is an inbuilt function in PHP which is used to add values to the font of the sequence. Syntax: void abstract public Ds\Sequence::unshift( $values ) Parameters: This function accepts a single parameter $values which contains values to add in the font of the sequenc 1 min read PHP | DsDeque shift() Function 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. Be 1 min read PHP array_unshift() Function This inbuilt function of PHP is used to add one or more elements into an array and these elements are added to at the beginning of the array. All the elements that we add into the array are inserted in the same order, as they have been passed. They are numerically indexed starting from the 0th posit 3 min read PHP | DsVector shift() Function The Ds\Vector::shift() function is an inbuilt function in PHP which is used to remove the first element from the vector and return it. Syntax: mixed public Ds\Vector::shift( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the value at index 0. Exce 1 min read Like