Php/docs/arrayiterator.current

提供:Dev Guides
< Php
移動先:案内検索

ArrayIterator::current

(PHP 5, PHP 7)

ArrayIterator::current現在の配列エントリを返す


説明

public ArrayIterator::current ( ) : mixed

現在の配列エントリを取得します。


パラメータ

この関数にはパラメータはありません。


返り値

現在の配列エントリを返します。


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

上の例の出力は以下となります。


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