(PHP 4, PHP 5, PHP 7, PHP 8)
next — 將數組中的內部指針向前移動(dòng)一位
next() 和 current() 的行為類(lèi)似,只有一點(diǎn)區別,在返回值之前將內部指針向前移動(dòng)一位。這意味著(zhù)它返回的是下一個(gè)數組單元的值并將數組指針向前移動(dòng)了一位。
array
受影響的 array 。
返回數組內部指針指向的下一個(gè)單元的值,或當沒(méi)有更多單元時(shí)返回 false
。
版本 | 說(shuō)明 |
---|---|
8.1.0 | 棄用在 object 上調用此函數。 在 object 優(yōu)先使用 get_mangled_object_vars() 或者使用 ArrayIterator。 |
示例 #1 next() 及相關(guān)函數的用法示例
<?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';
?>