The MultipleIterator class

- « LimitIterator::valid

- MultipleIterator::attachIterator »

- PHP Manual
- Iterators
- The MultipleIterator class

# The MultipleIterator class

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

## Introduction

An Iterator that sequentially iterates over all attached iterators

## Class synopsis

class MultipleIterator implements Iterator {
/* Constants */
public const int MIT_NEED_ANY;
public const int MIT_NEED_ALL;
public const int MIT_KEYS_NUMERIC;
public const int MIT_KEYS_ASSOC;
/* Methods */
public __construct(int `$flags` = MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC)
public attachIterator(Iterator `$iterator`, string|int|null `$info` = `null`): void
public containsIterator(Iterator `$iterator`): bool
public countIterators(): int
public current(): array
public detachIterator(Iterator `$iterator`): void
public getFlags(): int
public key(): array
public next(): void
public rewind(): void
public setFlags(int `$flags`): void
public valid(): bool
}

## Predefined Constants

`MultipleIterator::MIT_NEED_ANY`

  Do not require all sub iterators to be valid in iteration.

`MultipleIterator::MIT_NEED_ALL`

  Require all sub iterators to be valid in iteration.

`MultipleIterator::MIT_KEYS_NUMERIC`

  Keys are created from the sub iterators position.

`MultipleIterator::MIT_KEYS_ASSOC`

  Keys are created from sub iterators associated information.

## Table of Contents

- MultipleIterator::attachIterator — Attaches iterator information
- MultipleIterator::__construct — Constructs a new MultipleIterator
- MultipleIterator::containsIterator — Checks if an iterator is attached
- MultipleIterator::countIterators — Gets the number of attached iterator instances
- MultipleIterator::current — Gets the registered iterator instances
- MultipleIterator::detachIterator — Detaches an iterator
- MultipleIterator::getFlags — Gets the flag information
- MultipleIterator::key — Gets the registered iterator instances
- MultipleIterator::next — Moves all attached iterator instances forward
- MultipleIterator::rewind — Rewinds all attached iterator instances
- MultipleIterator::setFlags — Sets flags
- MultipleIterator::valid — Checks the validity of sub iterators