PHP中的next()函数
该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)."\n";
echo next($a)."\n";
echo current($a)."\n";
echo next($a)."\n";
echo end($a)."\n";
echo current($a)."\n";
?>输出结果
one two two three six six