配列の現在の要素の値と、次の要素の値を出力します:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo next($people);
?>
例の実行 »
next() 関数は、内部ポインタを配列の次の要素に移動し、出力します。
関連するメソッド:
next(array)
パラメータ | 説明 |
---|---|
array | 必須。使用する配列を指定する |
返り値: | 成功した場合は配列内の次の要素の値を返し、それ以上要素がない場合はFALSEを返します |
---|---|
PHP バージョン: | 4+ |
関連する全メソッドのデモ:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>"; // The current element is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe
echo current($people) . "<br>"; // Now the current element is Joe
echo prev($people) . "<br>"; // The previous element of Joe is Peter
echo end($people) . "<br>"; // The last element is Cleveland
echo prev($people) . "<br>"; // The previous element of Cleveland is Glenn
echo current($people) . "<br>"; // Now the current element is Glenn
echo reset($people) . "<br>"; // 内部ポインタを配列の最初の要素に移動する, which is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe
print_r (each($people)); // Returns the key and value of the current element (now Joe), and moves the internal pointer forward
?>
例の実行 »