ArrayIterator::current

(PHP 5, PHP 7, PHP 8)

ArrayIterator::currentReturn current array entry

Beschreibung

publicArrayIterator::current(): mixed

Get the current array entry.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

The current array entry.

Beispiele

Beispiel #1 ArrayIterator::current() example

<?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";
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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