Syntax:void SplDoublyLinkedList::offsetUnset ($index)
Parameters: this function takes one parameter $index,which contains an index value that is not set.Return value:returns no value. The following programs illustrate the function SplDoublyLinkedList::offsetUnset()in PHP:Program 1:
// Declare an empty SplDoublyLinkedList
$list
=
new
SplDoublyLinkedList;
// Use the SplDoublyLinkedList::add() function for
// add elements to SplDoublyLinkedList
$list
-> add (0, 30);
$list
-> add (1, 20);
$list
-> add (2, 30);
$list
-> add (3,
" Geeks "
);
$list
-> add (4,
’ G’
);
$list
->
rewind
();
// Use the SplDoublyLinkedList::offsetUnset() function
// reset the value at the given index
$list
-> offsetUnset (0);
$list
-> offsetUnset (1);
$list
-> offsetUnset (0);
$list
-> offsetUnset (1);
var_dump (
$list
);
?>
Exit:object (SplDoublyLinkedList ) # 1 (2) {["flags": "SplDoublyLinkedList": private] = > int (0) ["dllist": "SplDoublyLinkedList": private] = > array (1) {[0] = > string (5) "Geeks"}}
Program 2:
// Declare an empty SplDoublyLinkedList
$list
=
new
SplDoublyLinkedList ( );
// Use the SplDoublyLinkedList::push() function for
// add elements to SplDoublyLinkedList
$list
-> push (1);
$list
-> push (2);
$list
-> push (3);
$list
-> push (8);
$list
-> push (5);
// Use the SplDoublyLinkedList::offsetUnset() function
// reset the value at the given index
$list
-> offsetUnset (1);
$list
-> offsetUnset (2);
print_r (
$list
);
?>
Exit:SplDoublyLinkedList Object ( [flags: SplDoublyLinkedList: private] = > 0 [dllist: SplDoublyLinkedList: private] = > Array ([0] = > 1 [1] = > 3 [2] = > 5))
Link: https://www.php.net/manual/en/ spldoublylinkedlist.offsetunset.php