PHP 中的 next() 函数

phpprogrammingserver side programming更新于 2025/8/7 11:37:17

next() 函数将数组的内部数组指针前进到下一个元素。

语法

next(arr)

参数

  • arr − 指定的数组

返回

next() 函数成功时返回数组中下一个元素的值。如果没有其他可用元素,则返回 FALSE。

示例

下面是一个例子 −

<?php
$os = array('windows', 'mac', 'linux', 'solaris');
echo current($os) . "<br>";
echo next($os);
?>

输出

windows
mac

示例

让我们看另一个例子 −

<?php
$a = array('one', 'two', 'three', 'four', 'five', 'six' );
echo current($a)."
"; echo next($a)."
"; echo current($a)."
"; echo next($a)."
"; echo end($a)."
"; echo current($a)."
"; ?>

输出

one
two
two
three
six
six

相关文章