LimitIterator::__construct

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

LimitIterator::__constructConstruit un nouvel objet LimitIterator

Description

public LimitIterator::__construct(Iterator $iterator, int $offset = 0, int $limit = -1)

Construit un nouvel objet LimitIterator,depuis iterator avec un offset et une limite maximum limit

Liste de paramètres

iterator

L'Iterator à limiter.

offset

Position optionnelle de la limite.

limit

Nombre optionnelle de la limite.

Valeurs de retour

Le nouvel objet LimitIterator.

Erreurs / Exceptions

Envoie une OutOfRangeException si offset est inférieur à 0 ou si limit est inférieur à -1.

Exemples

Exemple #1 Exemple LimitIterator::__construct()

<?php
$ait 
= new ArrayIterator(array('a''b''c''d''e'));
$lit = new LimitIterator($ait13);
foreach (
$lit as $value) {
    echo 
$value "\n";
}
?>

L'exemple ci-dessus va afficher :

b
c
d

add a note add a note

User Contributed Notes

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