PHP | Ds\Stack pop() Function Last Updated : 18 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Stack::pop() function of PHP is used to remove the element present at the top of the Stack instance. This function also returns the top element of the stack after removing it. Syntax: mixed public Ds\Stack::pop ( void ) Parameters: This function does not accept any parameters.Return Value mixed This function returns the element present at the top of the Stack and removes it from the stack. Below programs illustrate the Ds\Stack::pop() function in PHP: Program 1: PHP <?php // PHP program to illustrate the // Ds\stack::pop() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); // Print the initial Stack print_r($stack); // Print the top element and remove it print_r($stack->pop()); // Print the Stack again print_r($stack); ?> Output: Ds\Stack Object ( [0] => GfG [1] => to [2] => Welcome ) GfG Ds\Stack Object ( [0] => to [1] => Welcome ) Program 2: PHP <?php // PHP program to illustrate the // Ds\stack::pop() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing Mixed value elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); $stack->push(10); $stack->push(5.5); // Print the Stack initially print_r($stack); // Print the top element and remove it print_r($stack->pop()); // Print the stack again print_r($stack); ?> Output: Ds\Stack Object ( [0] => 5.5 [1] => 10 [2] => GfG [3] => to [4] => Welcome ) 5.5 Ds\Stack Object ( [0] => 10 [1] => GfG [2] => to [3] => Welcome ) Reference: http://php.net/manual/en/ds-stack.pop.php Comment More infoAdvertise with us Next Article PHP | DsDeque pop() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_stack Similar Reads PHP | DsStack pop() Function The Ds\Stack::pop() function of PHP is used to remove the element present at the top of the Stack instance. This function also returns the top element of the stack after removing it. Syntax: mixed public Ds\Stack::pop ( void ) Parameters: This function does not accept any parameters.Return Value mix 2 min read 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 | DsVector pop() Function The Ds\Vector::pop() function is an inbuilt function in PHP which is used to remove the last element of a vector and return it. Syntax: mixed public Ds\Vector::pop( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the last element which removed from 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 set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 2 min read PHP | Ds\Stack pop() Function min read Like