The ArrayIterator class

(PHP 5, PHP 7, PHP 8)

Introduction

Allows the removal of elements, and the modification of keys or values while iterating over arrays or objects.

To iterate the same array more than once, it is recommended to instantiate ArrayObject and use the ArrayIterator instance either implicitly created when using foreach to iterate over the array stored internally, or create one by calling the ArrayObject::getIterator() method manually.

Class synopsis

class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable {
/* Constants */
public const int STD_PROP_LIST;
public const int ARRAY_AS_PROPS;
/* Methods */
public function __construct(array|object $array = [], int $flags = 0)
public function append(mixed $value): void
public