array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'limititerator.getposition.php', 1 => 'LimitIterator::getPosition', 2 => 'Return the current position', ), 'up' => array ( 0 => 'class.limititerator.php', 1 => 'LimitIterator', ), 'prev' => array ( 0 => 'limititerator.current.php', 1 => 'LimitIterator::current', ), 'next' => array ( 0 => 'limititerator.key.php', 1 => 'LimitIterator::key', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/limititerator/getposition.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

LimitIterator::getPosition

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

LimitIterator::getPositionReturn the current position

Descrizione

public LimitIterator::getPosition(): int

Gets the current zero-based position of the inner Iterator.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

The current position.

Esempi

Example #1 LimitIterator::getPosition() example

<?php
$fruits
= array(
'a' => 'apple',
'b' => 'banana',
'c' => 'cherry',
'd' => 'damson',
'e' => 'elderberry'
);
$array_it = new ArrayIterator($fruits);
$limit_it = new LimitIterator($array_it, 2, 3);
foreach (
$limit_it as $item) {
echo
$limit_it->getPosition() . ' ' . $item . "\n";
}
?>

Il precedente esempio visualizzerĂ :

2 cherry
3 damson
4 elderberry

Vedere anche: