array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'arrayiterator.current.php', 1 => 'ArrayIterator::current', ), 'up' => array ( 0 => 'class.arrayiterator.php', 1 => 'ArrayIterator', ), 'prev' => array ( 0 => 'arrayiterator.count.php', 1 => 'ArrayIterator::count', ), 'next' => array ( 0 => 'arrayiterator.getarraycopy.php', 1 => 'ArrayIterator::getArrayCopy', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/spl/arrayiterator/current.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
ArrayIterator::current — 現在の配列エントリを返す
この関数にはパラメータはありません。
現在の配列エントリを返します。
例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