PHP | Ds\Vector shift() Function Last Updated : 22 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Exception: This function throws UnderflowException if vector is empty. Below programs illustrate the Ds\Vector::shift() function in PHP: Program 1: PHP <?php // Declare an Vector $vect = new \Ds\Vector(["geeks", "of", "geeks"]); echo("First element in the vector:\n"); // Use shift() function to remove first // element from vector and display it var_dump($vect->shift()); ?> Output: First element in the vector: string(5) "geeks" Program 2: PHP <?php // Declare an Vector $vect = new \Ds\Vector([1, 2, 3, 4, 5, 6]); // Use shift() function to remove first // element from vector and display it var_dump($vect->shift()); var_dump($vect->shift()); var_dump($vect->shift()); var_dump($vect->shift()); ?> Output: int(1) int(2) int(3) int(4) Reference: http://php.net/manual/en/ds-vector.shift.php Comment More infoAdvertise with us Next Article PHP | DsDeque unshift() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads 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 | 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 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 | DsMap sort() Function The Ds\Map::sort() function of DS\Map class in PHP is used to in-place sort the elements of a specified Map instance according to the values. By default, the Map is sorted according to the increasing order of the values. Syntax: Ds\Pair public Ds\Map::sort ( int $position ) Parameter: This function 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 shift() Function 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 fir 1 min read PHP | Ds\Vector shift() Function min read Like