略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SplDoublyLinkedList::current

2024-11-14

SplDoublyLinkedList::current

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

SplDoublyLinkedList::currentReturn current array entry

说明

public SplDoublyLinkedList::current(): mixed

Get the current doubly linked list node.

参数

此函数没有参数。

返回值

The current node value.

add a noteadd a note

User Contributed Notes 1 note

up
1
rakesh dot mishra at gmail dot com
11 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();

?>

官方地址:https://www.php.net/manual/en/spldoublylinkedlist.current.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3