PHP następne function ()
Przykłady
Prąd wyjściowy elementu tablicy, a następnego elementu wartości:
<?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);
?>
Uruchomienie instancji »
Definicja i Wykorzystanie
Następna funkcja () w wewnętrznej wskaźnik do następnego elementu w tablicy, a wyjściem.
Podobne metody:
- PREV () - wewnętrzny wskaźnik do ostatniego elementu tablicy i wyjście.
- Prąd () - zwraca wartość bieżącego elementu tablicy.
- End () - wewnętrzny wskaźnik do ostatniego elementu w tablicy i wyjście.
- RESET () - wewnętrzny wskaźnik do pierwszego elementu tablicy, a wyjściem.
- each () - Zwraca nazwy klawiszy i wartości bieżącego elementu, a wewnętrzny wskaźnik porusza się do przodu.
gramatyka
next( array )
参数 | 描述 |
---|---|
array | 必需。规定要使用的数组。 |
dane techniczne
Zwraca: | Jeśli się powiedzie, zwracana wartość kolejnego elementu tablicy, jeśli nie więcej elementów tablicy zwraca FAŁSZ. |
---|---|
Wersja PHP: | 4+ |
Więcej przykładów
Przykład 1
Wszystkie odpowiednie metody prezentacji:
<?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
?>
Uruchomienie instancji »
Kompletna PHP Array Reference