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
$seq = new \Ds\Vector( [12, 15, 18, 20] );
var_dump( $seq ->pop());
var_dump( $seq ->pop());
var_dump( $seq ->pop());
var_dump( $seq ->pop());
?>
|
Output:
int(20)
int(18)
int(15)
int(12)
Program 2:
<?php
$seq = new \Ds\Vector([12, 15, 18, 20]);
for ( $i = 0; $i < 4; $i ++) {
var_dump( $seq ->pop());
}
?>
|
Output:
int(20)
int(18)
int(15)
int(12)
Reference: http://php.net/manual/en/ds-sequence.pop.php
Share your thoughts in the comments
Please Login to comment...