PHP 8.3.4 Released!

SeekableIterator::seek

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

SeekableIterator::seekRecherche une position

Description

public SeekableIterator::seek(int $offset): void

Recherche la position donnée dans l'itérateur.

Liste de paramètres

offset

La position à atteindre.

Valeurs de retour

Aucune valeur n'est retournée.

Erreurs / Exceptions

L'implémentations doit émettre une exception OutOfBoundsException si la position offset n'est pas atteignable.

Exemples

Exemple #1 Exemple avec SeekableIterator::seek()

Déplace l'itérateur à la position 3 (ArrayIterator implémente SeekableIterator).

<?php
$array
= array("apple", "banana", "cherry", "damson", "elderberry");
$iterator = new ArrayIterator($array);
$iterator->seek(3);
echo
$iterator->current();
?>

Résultat de l'exemple ci-dessus est similaire à :

damson

add a note

User Contributed Notes

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