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
$list = new \SplDoublyLinkedList;
$list ->add(0, 30);
$list ->add(1, 20);
$list ->add(2, 30);
$list ->add(3, "Geeks" );
$list ->add(4, 'G' );
$list -> rewind ();
var_dump( $list ->offsetGet(2));
var_dump( $list ->offsetGet(3));
?>
|
Output:
int(30)
string(5) "Geeks"
Complete List of PHP SPL SplDoublyLinkedList Functions:
Functions
|
Description
|
Example
|
add() |
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 Functions
Functions
|
Description
|
Example
|
count() |
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
Functions
|
Description
|
Example
|
addAll() |
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 current |
|
key() |
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 storage |
|
setInfo() |
Set the data associated with the current iterator entry. |
|
unserialize() |
Unserialize the storage from its serialize string |
|
valid() |
Check the current storage entry is valid or not. |
|
Complete List of PHP SPL SplQueue Functions:
Functions
|
Description
|
Example
|
__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. |
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
23 Jun, 2023
Like Article
Save Article