PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<natsortpos>
Last updated: Mon, 16 Jul 2012

next

(PHP 3, PHP 4, PHP 5)

next --  将数组中的内部指针向前移动一位

说明

mixed next ( array array )

返回数组内部指针指向的下一个单元的值,或当没有更多单元时返回 FALSE

next()current() 的行为类似,只有一点区别,在返回值之前将内部指针向前移动一位。这意味着它返回的是下一个数组单元的值并将数组指针向前移动了一位。如果移动指针的结果是超出了数组单元的末端,则 next() 返回 FALSE

警告

如果数组包含空的单元,或者单元的值是 0 则本函数碰到这些单元也返回 FALSE。要正确遍历可能含有空单元或者单元值为 0 的数组,参见 each() 函数。

例子 1. next() 及相关函数的用法示例

<?php
$transport
= array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$mode = next($transport);    // $mode = 'bike';
$mode = next($transport);    // $mode = 'car';
$mode = prev($transport);    // $mode = 'bike';
$mode = end($transport);    // $mode = 'plane';
?>

参见 current()end()prev()reset()




<natsortpos>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST