end function () de PHP
PHP matriz de referencia completa
Ejemplos
Corriente de salida de los elementos de matriz y el último elemento valores:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo end($people);
?>
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo end($people);
?>
Instancia en ejecución »
Definición y Uso
final () en el puntero interno al último elemento de la matriz, y la salida.
métodos relacionados:
- Corriente () - Devuelve el valor del elemento actual en la matriz.
- Siguiente () - Mueve el puntero interno al siguiente elemento de la matriz, y la salida.
- PREV () - Mueve el puntero interno al último elemento de la matriz, y la salida.
- RESET () - el puntero interno al primer elemento de la matriz, y la salida.
- la each () - Devuelve los nombres y los valores de la clave del elemento actual y el puntero interno se mueve hacia adelante.
gramática
end( array )
参数 | 描述 |
---|---|
array | 必需。规定要使用的数组。 |
detalles técnicos
Devuelve: | Si tiene éxito, entonces el valor del último elemento de la matriz se devuelve, si la matriz está vacío, devuelve FALSE. |
---|---|
versión de PHP: | 4+ |
más ejemplos
Ejemplo 1
Todos los métodos de presentación 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
?>
Instancia en ejecución »
PHP matriz de referencia completa