PHP 8.3.4 Released!

LimitIterator::getPosition

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

LimitIterator::getPositionRetourne la position courante

Description

public LimitIterator::getPosition(): int

Retourne la position (partant de zéro) de l'itérateur interne Iterator.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

La position courante.

Exemples

Exemple #1 Exemple LimitIterator::getPosition()

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

L'exemple ci-dessus va afficher :

2 cherry
3 damson
4 elderberry

Voir aussi

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top