php8.5
Home/ Manual/ ds / deque/ Ds\Deque::shift

Ds\Deque::shift

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Removes and returns the first value

Description

Ds\Deque::shift(): mixed

Removes and returns the first value.

Parameters Parameters

Return Values

The first value, which was removed.

Errors/Exceptions

UnderflowException if empty.

Examples

Ds\Deque::shift() example

php
<?php
$deque = new \Ds\Deque(["a", "b", "c"]);

var_dump($deque->shift());
var_dump($deque->shift());
var_dump($deque->shift());
?>

The above example will output something similar to:

output
string(1) "a"
string(1) "b"
string(1) "c"

Source: reference/ds/ds/deque/shift.xml · from the official PHP manual (php/doc-en)