PHP SPL Data structures Complete Reference Last Updated : 05 May, 2025 Comments Improve Suggest changes 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 SPL Data structures Complete Reference S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-SplFileInfo Similar Reads PHP DsMap Functions Complete Reference A Map is a sequential collection of key-value pair which is very similar to the array. The key of a map can be of any type and it is unique. If any value added to the same key in a Map then the map value will replace. It is the efficient Data Structure in PHP 7 to provide the alternative of an array 3 min read PHP DOM Functions Complete Reference PHP DOM extension is used to operate on XML documents using DOM API. The DOM extension uses UTF-8 encoding. The Complete list of PHP DOM Functions are listed below: DOMAttr PHP DOMAttr __construct() FunctionPHP DOMAttr isId() Function DOMCdataSection PHP DOMCdataSection __construct() Function DOMCha 2 min read PHP DsStack 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 DsSet Functions Complete Reference Set is the collection of unique values. The implementation of Ds\Set is similar to the Ds\Map which creates a hash table. The values of Ds\Set are used as key and the mapped values are ignored. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easie 2 min read PHP DsQueue Functions Complete Reference A Queue is a linear data structure that follows a particular order in which the operations are performed. The order of queue is First In First Out (FIFO). Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by usi 2 min read Like