php8.5
Home/ Manual/ reference / spl/ The ArrayIterator class

The ArrayIterator class

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

Intro

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 implements ArrayAccess implements Serializable implements Countable { }

Predefined Constants

ArrayIterator Flags

ArrayIterator::STD_PROP_LIST

Properties of the object have their normal functionality when accessed as list (var_dump(), Foreach, etc.).

ArrayIterator::ARRAY_AS_PROPS

Entries can be accessed as properties (read and write).

Changelog

VersionDescription

Arrayiterator

In this section

Source: reference/spl/arrayiterator.xml · from the official PHP manual (php/doc-en)