PHP | Ds\Deque pop() Function Last Updated : 14 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Deque::pop() function is an inbuilt function in PHP which is used to remove the last element from Deque (if Deque is not empty) and return it. If Deque is empty then it throws an exception. Syntax: public Ds\Deque::pop( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the removed last element from the Deque. Below programs illustrate the Ds\Deque::pop() function in PHP: Program 1: PHP <?php // Declare a deque $deck = new \Ds\Deque([10, 20, 30, 40, 50, 60]); echo("Elements of Deque\n"); // Display the Deque elements print_r($deck); // last element in the deque echo("\nLast element of deque: "); // Use pop() function to removing last // element from Deque and Display it print_r($deck->pop()); echo("\nElements of Deque\n"); // Display the Deque elements print_r($deck); ?> Output: Elements of Deque Ds\Deque Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 ) Last element of deque: 60 Elements of Deque Ds\Deque Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 ) Program 2: PHP <?php // Declare a deque $deck = new \Ds\Deque(["geeks", "for", "geeks", "practice"]); echo("Elements of Deque\n"); // Display the Deque elements print_r($deck); // last element in the deque echo("\nLast element of deque: "); // Use pop() function to removing last // element from Deque and Display it print_r($deck->pop()); echo("\nElements of Deque\n"); // Display the Deque elements print_r($deck); ?> Output: Elements of Deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks [3] => practice ) Last element of deque: practice Elements of Deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks ) Reference: http://php.net/manual/en/ds-deque.pop.php Comment More infoAdvertise with us Next Article PHP DsQueue pop() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_deque Similar Reads PHP | DsDeque pop() Function The Ds\Deque::pop() function is an inbuilt function in PHP which is used to remove the last element from Deque (if Deque is not empty) and return it. If Deque is empty then it throws an exception. Syntax: public Ds\Deque::pop( void ) : mixed Parameters: This function does not accept any parameter. R 2 min read PHP DsQueue pop() Function The Ds\Queue::pop() Function in PHP is used to remove and return the value present at the top of the Queue. In other words, it returns the value present at the front of the Queue and also removes it from the Queue. Syntax: mixed public Ds\Queue::pop ( void ) Parameters: This function does not accept 2 min read PHP | DsSequence pop() Function The Ds\Sequence::pop() function is an inbuilt function in PHP which removes the last value from sequence and return it. Syntax: abstract public Ds\Sequence::pop( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the popped value. Below progra 1 min read PHP | DsDeque push() Function The Ds\Deque::push() function is an inbuilt function in PHP which is used to add the elements to the Deque by appending an element at the end of the Deque. Syntax: public Ds\Deque::push( $values ) : void Parameters: This function accepts single parameter $values which holds the elements to be added 2 min read PHP | DsDeque find() Function The Ds\Deque::find() function is an inbuilt function in PHP which is used to find the index of the element in the Deque if element found in the Deque.Syntax: public Ds\Deque::find( $value ) : mixed Parameters: This function accepts single parameter $value which holds the element whose index is to be 2 min read PHP | DsDeque sort() Function The Ds\Deque::sort() function is an inbuilt function in PHP which is used to sort the Deque in place by arranging the elements in increasing order. Syntax: public Ds\Deque::sort( $comparator ) : void Parameters::This function accepts single parameter $comparator which holds the function to decides h 2 min read PHP | Ds\Deque pop() Function min read Like