PHP Basics

IteratorTrait

A generic implementation of the Iterator interface.

Internally it iterates over the protected $_data array.

Tags
author

Sebastian Meyer sebastian.meyer@opencultureconsulting.com

template

TValue of mixed

Table of Contents

Methods

current()  : TValue|null
Return the current item.
key()  : string|int|null
Return the current key.
next()  : void
Move forward to next item.
prev()  : void
Move back to previous item.
rewind()  : void
Rewind the iterator to the first item.
valid()  : bool
Check if current position is valid.

Methods

current()

Return the current item.

public current() : TValue|null
APIYes
Return values
TValue|null

The current item or NULL if invalid

key()

Return the current key.

public key() : string|int|null
APIYes
Return values
string|int|null

The current key or NULL if invalid

next()

Move forward to next item.

public next() : void
APIYes

prev()

Move back to previous item.

public prev() : void
APIYes

rewind()

Rewind the iterator to the first item.

public rewind() : void
APIYes

valid()

Check if current position is valid.

public valid() : bool
APIYes
Return values
bool

Whether the current position is valid


        
On this page

Search results