$dll = new SplDoublyLinkedList();$dll->push(2);$dll->push(3);$dll->unshift(5); // add 5 beginning of the array$dll->rewind();while($dll->valid()){ echo $dll->current()."\n"; $dll->next();}Output 523
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
SplDoublyLinkedList::unshift — Acrescenta um elemento ao início da lista duplamente encadeada
Acrescenta value
ao início da lista duplamente encadeada.
value
O valor a ser acrescentado.
Nenhum valor é retornado.
$dll = new SplDoublyLinkedList();$dll->push(2);$dll->push(3);$dll->unshift(5); // add 5 beginning of the array$dll->rewind();while($dll->valid()){ echo $dll->current()."\n"; $dll->next();}Output 523