The ArrayIterator class

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

ArrayIterator
implements SeekableIterator ArrayAccess Serializable Countable
/* Constants */
public const int ArrayIterator::STD_PROP_LIST;
public const int ArrayIterator::ARRAY_AS_PROPS;
/* Methods */
public __construct(arrayobject $array = [], int $flags = 0)
public void append(mixed $value)
public true asort(int $flags = SORT_REGULAR)
public int count()
public mixed current()
public array getArrayCopy()
public int getFlags()
public stringintnull key()
public true ksort(int $flags = SORT_REGULAR)
public true natcasesort()
public true natsort()
public void next()
public bool offsetExists(mixed $key)
public mixed offsetGet(mixed $key)
public void offsetSet(mixed $key, mixed $value)
public void offsetUnset(mixed $key)
public void rewind()
public void seek(int $offset)
public string serialize()
public void setFlags(int $flags)
public true uasort(callable $callback)
public true uksort(callable $callback)
public void unserialize(string $data)
public bool valid()

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).

Table of Contents