ArrayIterator::current

(PHP 5, PHP 7, PHP 8)

ArrayIterator::currentRetourne l'entrée courante du tableau

Description

publicArrayIterator::current(): mixed

Retourne l'entrée courante du tableau.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

L'entrée courante du tableau.

Exemples

Exemple #1 Exemple avec ArrayIterator::current()

<?php
$array
= array('1' => 'one',
'2' => 'two',
'3' => 'three');

$arrayobject = new ArrayObject($array);

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

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

L'exemple ci-dessus va afficher :

1 => one 2 => two 3 => three
To Top