update page now
PHP 8.1.34 Released!

SplDoublyLinkedList::current

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplDoublyLinkedList::currentReturn current array entry

Description

public SplDoublyLinkedList::current(): mixed

Get the current doubly linked list node.

Parameters

This function has no parameters.

Return Values

The current node value.

add a note

User Contributed Notes 1 note

up
2
rakesh dot mishra at gmail dot com
14 years ago
<?php

/*
 * Examples of DoublyLinkedList
 */

$obj = new SplDoublyLinkedList();
/ Check wither linked list is empty
if ($obj->isEmpty())
{
    echo "Adding nodes to Linked List<br>";
    $obj->push(2);
    $obj->push(3);
    echo "Adding the node at beginning of doubly linked list <br>";
    $obj->unshift(10);
}

echo "<br>Our Linked List:";
print_r($obj);

$curr = $obj->current(); / this will return NULL as we have not set initial node.

echo "<br> Rewinding the position so that current node points to first node ";
$obj->rewind(); 

echo "<br>Current node of the linked list:";
echo  $obj->current(); / this will print first node of the linked list.

echo "<br>Moving to Next node:";
$obj->next();

echo "<br>Printing the next node:";
echo $obj->current();

?>
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant