: This article mainly introduces the SPL data structure of the php Standard Library ----- spldoublyshortlist (two-way linked list). For more information about PHP tutorials, see.
$ Spl = new SplDoublyLinkedList (); // instantiate the object of the two-way linked list $ spl-> push ("sdfsaf"); // add it to the top (top) (tail) of the linked list) $ spl-> push (111); $ spl-> push ('1'); $ spl-> unshift ("100 "); // the value before the bottom header is added to the bottom of the linked list. The value is $ spl-> shift (); // you can delete the bottom header) position value $ spl-> pop (); // The top Value $ spl-> top () is displayed. // Obtain the top (tail) element $ spl-> count (); // number of nodes $ spl-> isEmpty (); // whether the current value is empty, if it is null, return true $ spl-> rewind (); // move to the position of the bottom (header) $ spl-> current (); // get the value of the current node $ spl-> next (); // Move the node down $ spl-> prev (); // return to the previous node // The cyclic traversal chain table $ spl-> rewind (); while ($ name = $ spl-> current () {echo $ name. "\ n"; $ spl-> next ();} /*************************************** * *******************************/for ($ spl-> rewind (); $ spl-> valid (); $ spl-> next () {echo $ spl-> current (). "\ n" ;}var_dump ($ spl-> valid (); // if the node is a valid node, true is returned; otherwise, false is returned. // note: before $ spl-> current (), $ spl-> valid (), you must $ spl-> rewind (); otherwise, point to an empty node.
The above introduces the SPL data structure of the php Standard Library ----- SplDoublyLinkedList (two-way linked list), including the content, hope to be helpful to friends who are interested in PHP tutorials.