<?php
$q = new SplQueue();
$q->setIteratorMode(SplQueue::IT_MODE_DELETE);
$q->enqueue('item 1');
$q->enqueue('item 2');
$q->enqueue('item 3');
$q->dequeue();
$q->dequeue();
foreach ($q as $item) {
echo $item;
}
//Result: item 3
$q->dequeue(); //Fatal error: Uncaught exception 'RuntimeException'
//with message 'Can't shift from an empty datastructure'
?>
SplQueue::dequeue
(PHP 5 >= 5.3.0)
SplQueue::dequeue — Dequeues a node from the queue
Description
Dequeues value from the top of the queue.
Note:
SplQueue::dequeue() is an alias of SplDoublyLinkedList::shift().
Parameters
This function has no parameters.
Return Values
The value of the dequeued node.
andresdzphp at php dot net
30-Sep-2011 11:10
xuecan at gmail dot com
20-Jan-2010 08:57
If the queue is empty, dequeue() will raise an 'RuntimeException' with message 'Can't shift from an empty datastructure'.
