class Iterator extends ArrayIterator (View source)

Constants

STD_PROP_LIST

ARRAY_AS_PROPS

Methods

__construct(array $array = [], int $flags = 0, $iterator_class = null)

Construct an ArrayIterator

bool
offsetExists(string $key)

Check if offset exists

mixed
offsetGet(string $key)

Get value for an offset

void
offsetSet(string $key, TValue $value)

Set value for an offset

void
offsetUnset(string $key)

Unset value for an offset

void
append(mixed $value)

Append an element

array
getArrayCopy()

Get array copy

int
count()

Count elements

int
getFlags()

Get flags

void
setFlags(string $flags)

Set behaviour flags

asort(int $flags = SORT_REGULAR)

Sort array by values

ksort(int $flags = SORT_REGULAR)

Sort array by keys

uasort(callable $callback)

User defined sort

uksort(callable $callback)

User defined sort

natsort()

Sort an array naturally

natcasesort()

Sort an array naturally, case insensitive

void
unserialize(string $data)

Unserialize

string|null
serialize()

Serialize

void
rewind()

Rewind array back to the start

mixed
current()

Return current array entry

mixed
key()

Return current array key

void
next()

Move to next entry

bool
valid()

Check whether array contains more entries

void
seek(int $offset)

Seek to position

array
__debugInfo()

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

Details

__construct(array $array = [], int $flags = 0, $iterator_class = null)

Construct an ArrayIterator

Parameters

array $array

The array or object to be iterated on.

int $flags

Flags to control the behaviour of the ArrayObject object.

$iterator_class

See also

ArrayObject::setFlags

bool offsetExists(string $key)

Check if offset exists

Parameters

string $key

The offset being checked.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

mixed offsetGet(string $key)

Get value for an offset

Parameters

string $key

The offset to get the value from.

Return Value

mixed

Can return all value types.

void offsetSet(string $key, TValue $value)

Set value for an offset

Parameters

string $key

The index to set for.

TValue $value

The value to set.

Return Value

void

void offsetUnset(string $key)

Unset value for an offset

Parameters

string $key

The offset to unset.

Return Value

void

void append(mixed $value)

Append an element

Parameters

mixed $value

The value to append.

Return Value

void

array getArrayCopy()

Get array copy

Return Value

array

A copy of the array, or array of public properties if ArrayIterator refers to an object.

int count()

Count elements

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

int getFlags()

Get flags

Return Value

int

The current flags.

void setFlags(string $flags)

Set behaviour flags

Parameters

string $flags

A bitmask as follows: 0 = Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.). 1 = Array indices can be accessed as properties in read/write.

Return Value

void

asort(int $flags = SORT_REGULAR)

Sort array by values

Parameters

int $flags

ksort(int $flags = SORT_REGULAR)

Sort array by keys

Parameters

int $flags

uasort(callable $callback)

User defined sort

Parameters

callable $callback

The compare function used for the sort.

uksort(callable $callback)

User defined sort

Parameters

callable $callback

The compare function used for the sort.

natsort()

Sort an array naturally

natcasesort()

Sort an array naturally, case insensitive

void unserialize(string $data)

Unserialize

Parameters

string $data

The string representation of the object.

Return Value

void

string|null serialize()

Serialize

Return Value

string|null

The string representation of the object or null

void rewind()

Rewind array back to the start

Return Value

void

Any returned value is ignored.

mixed current()

Return current array entry

Return Value

mixed

Can return any type.

mixed key()

Return current array key

Return Value

mixed

TKey on success, or null on failure.

void next()

Move to next entry

Return Value

void

Any returned value is ignored.

bool valid()

Check whether array contains more entries

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

void seek(int $offset)

Seek to position

Parameters

int $offset

The position to seek to.

Return Value

void

array __debugInfo()

Since: 7.4

No description

Return Value

array

array __serialize()

Since: 7.4

No description

Return Value

array

void __unserialize(array $data)

Since: 7.4

No description

Parameters

array $data

Return Value

void