PHP | Ds\Vector pop() Function Last Updated : 22 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 the vector. Below programs illustrate the Ds\Vector::pop() function in PHP: Program 1: PHP <?php // Create new Vector $arr1 = new \Ds\Vector([10, 20, 30, 40, 50]); echo("Original vector elements\n"); print_r($arr1); echo("Last element in vector: "); // Use pop() function to remove // last element from vector var_dump($arr1->pop()); echo("\nVector after removing the last element\n"); print_r($arr1); ?> Output: Original vector elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 ) Last element in vector: int(50) Vector after removing the last element Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 ) Program 2: PHP <?php // Create new Vector $arr1 = new \Ds\Vector(["geeks", "for", "geeks"]); echo("Original vector elements\n"); print_r($arr1); echo("Last element in vector: "); // Use pop() function to remove // last element from vector var_dump($arr1->pop()); echo("\nVector after removing the last element\n"); print_r($arr1); ?> Output: Original vector elements Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Last element in vector: string(5) "geeks" Vector after removing the last element Ds\Vector Object ( [0] => geeks [1] => for ) Reference: http://php.net/manual/en/ds-vector.pop.php Comment More infoAdvertise with us Next Article PHP | DsMap remove() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector 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 | DsMap remove() Function The Ds\Map::remove() function is an inbuilt function in PHP which is used to remove and return a value by key. Syntax: mixed Ds\Map::remove( $key, $default ) Parameters: This function accepts two parameters as mentioned above and described below: $key: It holds the key value which need to remove. $d 2 min read PHP | DsMap xor() Function The Ds\Map::xor() function is an inbuilt function in PHP which is used to create a new map which contains the value either in the first map or second map but not both. Syntax: Ds\Map public Ds\Map::xor ( Ds\Map $map ) Parameter: This parameter holds the other map of values. Return value: It is used 2 min read PHP | Ds\Vector pop() Function min read Like