$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 — 双方向リンクリストの先頭に要素を追加する
value
追加する値。
値を返しません。
$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