当前位置:  首页>> 技术小册>> PHP合辑5-SPL标准库

SplDoublyLinkedList::bottom()函数是PHP中的内置函数,用于查看双向链表开头节点的值。

语法:

mixed SplDoublyLinkedList::bottom( void )
参数:它不接受任何参数。

返回值:它返回双向链表中的第一个节点的值。

示例:

  1. <?php
  2. // Declare an empty SplDoublyLinkedList
  3. $list = new \SplDoublyLinkedList;
  4. // Use SplDoublyLinkedList::push() function to
  5. // add elements to the SplDoublyLinkedList
  6. $list->push(1);
  7. $list->push(2);
  8. $list->push(3);
  9. $list->push(8);
  10. $list->push(5);
  11. // Use bottom() function
  12. $val = $list->bottom();
  13. // Display result
  14. print_r($val);
  15. ?>

output:

  1. 1

该分类下的相关小册推荐: