PHP次の()関数
例
出力電流の配列要素と次の要素値:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo next($people);
?>
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo next($people);
?>
実行中のインスタンス»
定義と使用法
アレイ、および出力の次の要素への内部ポインタの次の()関数。
関連するメソッド:
- PREV() -配列、および出力の最後の要素への内部ポインタ。
- 現在() -配列内の現在の要素の値を返します。
- エンド() -配列、および出力の最後の要素への内部ポインタ。
- RESET() -内部の配列の最初の要素へのポインタ、および出力。
- 各() -現在の要素のキー名と値を返し、内部ポインタが前進します。
文法
next( array )
参数 | 描述 |
---|---|
array | 必需。规定要使用的数组。 |
技術的詳細
戻り値: | 成功した場合、配列要素の戻り次の配列要素の値、そうでない場合よりはFALSEを返します。 |
---|---|
PHPバージョン: | 4+ |
より多くの例
例1
関連するすべてのプレゼンテーションの方法:
<?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>"; // Moves the internal pointer to the first element of the array, 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
?>
$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>"; // Moves the internal pointer to the first element of the array, 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
?>
実行中のインスタンス»
完全なPHPの配列参照