PHP SplDoublyLinkedList current () Function

PHP

Syntax:
mixed SplDoublyLinkedList::current (void)
Parameters:takes no parameters.Returned value:Returns the current value of a node in a doubly linked list.Below programs illustrate the function SplDoublyLinkedList::current()in PHP:Program 1:  
// 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); $list -> rewind ();  
// Using the current() function print_r ( $list -> current());  
?>
Exit:
1
Program 2:  
// 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 ();  
// Using the current() function print_r ( $list -> current());  
?>
Exit:
30
Link: https://www.php.net/manual/ en / spldoublylinkedlist.current.php



Get Solution for free from DataCamp guru