企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 实例 ``` <?php $dlist=new SplDoublyLinkedList(); $dlist->push('hiramariam'); $dlist->push('maaz'); $dlist->push('zafar'); /* the list contains hiramariam maaz zafar */ $dlist->unshift(1); $dlist->unshift(2); $dlist->unshift(3); /* the list now contains 3 2 1 hiramariam maaz zafar */ $dlist->pop(); /* the list now contains 3 2 1 hiramariam maaz */ // 从头部删除 $dlist->shift(); /* the list now contains 2 1 hiramariam maaz */ // 根据 index 替换,不存在抛异常 // add($index, $newval) $dlist->add(3 , 2.24); for($dlist->rewind();$dlist->valid();$dlist->next()){ echo $dlist->current()."\n"; } echo "\n"; // 设置先进先出 $dlist->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); for($dlist->rewind();$dlist->valid();$dlist->next()){ echo $dlist->current()."\n"; } ```