PHP SPL Data structures Complete Reference Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Standard PHP Library (SPL) the collection of standard data structures. The SPL data structure grouped the contents according to their implementation.Example: Below programs illustrate the SplDoublyLinkedList::offsetGet() function in PHP: PHP <?php // Declare an empty SplDoublyLinkedList $list = new \SplDoublyLinkedList; // Use SplDoublyLinkedList::add() function to // add elements to the SplDoublyLinkedList $list->add(0, 30); $list->add(1, 20); $list->add(2, 30); $list->add(3, "Geeks"); $list->add(4, 'G'); $list->rewind(); // Use SplDoublyLinkedList::offsetGet() function // to check index exist or not var_dump($list->offsetGet(2)); var_dump($list->offsetGet(3)); ?> Output:int(30)string(5) "Geeks"Complete List of PHP SPL SplDoublyLinkedList Functions:FunctionsDescriptionadd()Add a new value at the given index.bottom()Peek the value of the node from the beginning of the doubly linked list.count()Count the number of elements present in a doubly linked list.current()Return the current element of the array.isEmpty()Check whether the doubly linked list is empty or not.key()Return the index of the current node.next()Move the index into next index.offsetExists()Check whether the given index exists or not.offsetGet()Returns the value at the given index.offsetSet()Set the value at the given index.offsetUnset()That is used to unset the value at the given index.pop()pop the node from the end of the doubly linked list.prev()Move to the previous entry.push()Push an element at the end of the doubly linked list.rewind()Rewind the iterator back to the start or beginning.shift()Shift the node from the beginning of the doubly linked list.top()Return the value of the last (top) node in a doubly-linked list.unshift()Add the element at the beginning of a doubly linked list.Complete List of PHP SPL SplFixedArray FunctionsFunctionsDescriptioncount()Return the size of the array.current()Get the current entry of the array.getSize()Get the size of the array.key()Get the key of the current index of the array.next()Move the array element to the next entry of the array.offsetExists()Check provided index exist or not in an array.offsetGet()Get the offset of the specified index in an array.offsetUnset()Unset the value of the requested index.rewind()Rewind the array iterator to the start position.setSize()Set the size of the array.toArray()Get a PHP array from the fixed array.valid()Check the array can contain more elements or not.Complete List of PHP SPL SplObjectStorage Functions FunctionsDescriptionaddAll()Add elements from another storage.attach()Add objects into the SplObjectStorage.contains()Check whether the storage object contains a specified object or not.count()Count the number of objects in storage.current()Get the current entry of storage.detach()Remove objects from the storage.getinfo()Get the data associated with the object by the currentkey()Get the index of the currently pointing iterator.next()Move to the next entry of storage. offsetExists()Check the object exists in storage or not.offsetGet()Get the data associated with the object.offsetSet()Set the object of storage.offsetUnset()Set the object from the storage.removeAll()Remove all objects contained in another storage from the current storage.removeAllExcept()Remove all objects from storage except for those contains in another storage.rewind()Rewind the iterator to the first storage element.serialize()Serialize the result of the storagesetInfo()Set the data associated with the current iterator entry.unserialize()Unserialize the storage from its serialize stringvalid()Check the current storage entry is valid or not.Complete List of PHP SPL SplQueue Functions:FunctionsDescription__construct()Construct a queue that is implemented using a doubly-linked list.dequeue()Dequeue the node from the queue.enqueue()Add the element to the queue. Comment More infoAdvertise with us Next Article PHP Ds\Stack Functions Complete Reference S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-SplFileInfo Similar Reads PHP Ds\Stack Functions Complete Reference Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). The Ds\Stack uses Ds\Vector internally. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Inst 2 min read PHP Ds\Stack Functions Complete Reference Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). The Ds\Stack uses Ds\Vector internally. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Inst 2 min read PHP Ds\Sequence Functions Complete Reference A Sequence is used to arrange the values in a single and linear dimension way. In some languages, the sequence refers to the List. The sequence is similar to the array which is used as incremental integer keys are listed below: The index value of the sequence are [0, 1, 2, â¦, size - 1], where size r 3 min read PHP Ds\Sequence Functions Complete Reference A Sequence is used to arrange the values in a single and linear dimension way. In some languages, the sequence refers to the List. The sequence is similar to the array which is used as incremental integer keys are listed below: The index value of the sequence are [0, 1, 2, â¦, size - 1], where size r 3 min read PHP Ds\Vector Functions Complete Reference A Vector Data Structure is used to store the sequence of values in a contiguous memory buffer which grows and shrinks automatically. The vector data structure mapped the index value to its index buffer and the growth factor isn't bound to a specific multiple or exponent. It is the efficient Data Str 3 min read PHP Ds\Vector Functions Complete Reference A Vector Data Structure is used to store the sequence of values in a contiguous memory buffer which grows and shrinks automatically. The vector data structure mapped the index value to its index buffer and the growth factor isn't bound to a specific multiple or exponent. It is the efficient Data Str 3 min read Like