Dutch PHP Conference 2025 - Call For Papers

ArrayIterator::current

(PHP 5, PHP 7, PHP 8)

ArrayIterator::currentDevuelve la entrada actual del array

Descripción

public ArrayIterator::current(): mixed

Obtiene la entrada actual del array.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

La entrada actual del array.

Ejemplos

Ejemplo #1 Ejemplo de ArrayIterator::current()

<?php
$array
= array('1' => 'uno',
'2' => 'dos',
'3' => 'tres');

$arrayobject = new ArrayObject($array);

for(
$iterator = $arrayobject->getIterator();
$iterator->valid();
$iterator->next()) {

echo
$iterator->key() . ' => ' . $iterator->current() . "\n";
}
?>

El resultado del ejemplo sería:

1 => uno
2 => dos
3 => tres

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top