ArrayIterator
PHP Manual

ArrayIterator::current

(PHP 5 >= 5.1.0)

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

説明

mixed ArrayIterator::current ( void )

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

パラメータ

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

返り値

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

例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


ArrayIterator
PHP Manual
アダルトレンタルサーバー