Skip to content
Related Articles

Related Articles

PHP | Ds\Sequence pop() Function
  • Last Updated : 24 Jan, 2019

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 programs illustrate the Ds\Sequence::pop() function in PHP:



Program 1:




<?php
   
// Create new sequence
$seq new \Ds\Vector( [12, 15, 18, 20] );
  
// pop the sequence element
var_dump($seq->pop());
  
// pop the sequence element
var_dump($seq->pop());
  
// pop the sequence element
var_dump($seq->pop());
  
// pop the sequence element
var_dump($seq->pop());
?>

Output:

int(20)
int(18)
int(15)
int(12)

Program 2:




<?php
   
// Create new sequence
$seq new \Ds\Vector([12, 15, 18, 20]);
  
for ($i = 0; $i < 4; $i++) {
  
    // Pop the sequence element
    var_dump($seq->pop());
}
  
?>

Output:

int(20)
int(18)
int(15)
int(12)

Reference: http://php.net/manual/en/ds-sequence.pop.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :