<?php
$list = new SplDoublyLinkedList();
// adding elements with push or unshift
$list->push(1);
$list->push(10);
$list->push(100);
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
loop($list);
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO
| SplDoublyLinkedList::IT_MODE_DELETE);
loop($list);
echo 'count: ' . count($list);
function loop(Traversable $list) {
foreach ($list as $element) {
echo $element . PHP_EOL;
}
}