phpday 2027 - Call for Papers

Iterator::rewind

(PHP 5, PHP 7, PHP 8)

Iterator::rewind — Rebobine la Iterator al primer elemento

Descripción

public function Iterator::rewind(): void

Rebobina de nuevo al primer elemento de la Iterator.

Nota:

Este es el primer método llamado cuando se inicia un foreach bucle. No va a ser ejecutado despues foreach bucle.

Como foreach siempre llama a este método antes de iniciar la iteración, avanzar manualmente la posición del iterador (por ejemplo mediante SplFileObject::seek()) será reiniciado.

Para iterar sin rebobinar el iterador, envuélvalo en un NoRewindIterator.

Parámetros

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

Valores devueltos

Cualquier valor devuelto se pasa por alto.

User Contributed Notes 1 note

up
18
al
10 years ago
Builtin PHP function is »reset«.

Don't mix this with builtin function »rewind« which operates on file handle.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top