PHP 8.5.0 Alpha 2 available for testing

LimitIterator::getPosition

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

LimitIterator::getPositionDevuelve la posición actual

Descripción

public LimitIterator::getPosition(): int

Devuelve la posición (partiendo de cero) del iterador interno Iterator.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

La posición actual.

Ejemplos

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

El ejemplo anterior mostrará :

2 cherry
3 damson
4 elderberry

Ver también

add a note

User Contributed Notes

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