ArrayIterator::current

(PHP 5, PHP 7)

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

Description

public ArrayIterator::current ( void ) : 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