PHP função next ()
PHP completa matriz de referência
Exemplos
Corrente de saída de elementos de matriz e o elemento seguinte valores:
<?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);
?>
Correndo instância »
Definição e Uso
próxima função () no ponteiro interno para o próximo elemento da matriz e de saída.
métodos relacionados:
- PREV () - o ponteiro interno para o último elemento da matriz, e de saída.
- Atual () - Retorna o valor do elemento atual na matriz.
- End () - o ponteiro interno para o último elemento na matriz, e de saída.
- RESET () - o ponteiro interno para o primeiro elemento na matriz, e de saída.
- a each () - Retorna nomes e valores de chave do elemento atual, e o ponteiro interno avança.
gramática
next( array )
参数 | 描述 |
---|---|
array | 必需。规定要使用的数组。 |
detalhes técnicos
retorna: | Se for bem sucedido, o valor de retorno do próximo elemento da matriz, se não mais dos elementos da matriz retorna FALSE. |
---|---|
versão do PHP: | 4+ |
mais exemplos
exemplo 1
Todos os métodos de apresentação relevantes:
<?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
?>
Correndo instância »
PHP completa matriz de referência