The IteratorAggregate interface

(PHP 5, PHP 7, PHP 8)


Interface to create an external Iterator.

Interface synopsis

interface IteratorAggregate extends Traversable {
/* Methods */

Example #1 Basic usage

class myData implements IteratorAggregate {
$property1 "Public property one";
$property2 "Public property two";
$property3 "Public property three";

    public function 
__construct() {
$this->property4 "last property";

    public function 
getIterator() {
        return new 

$obj = new myData;

$obj as $key => $value) {

The above example will output something similar to:

string(9) "property1"
string(19) "Public property one"

string(9) "property2"
string(19) "Public property two"

string(9) "property3"
string(21) "Public property three"

string(9) "property4"
string(13) "last property"

Table of Contents

Here you can write a comment

Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

Total Commander 11.00 (final) is available! What's new?

Total Commander, a popular file manager, has recently released its latest version, 11.00. With a variety of new features and corrections, this version offers users an enhanced and optimized experience. ...


Autor : admin
Category: Software-Updates

Which technologies should a PHP programmer master?

In today's digital world, the role of a PHP programmer is of great importance. ...


Autor : admin
Category: Miscellaneous

PHPUnit version 10 released

PHPUnit version 10 released

Version 10 of the popular test framework PHPUnit has been released and is available for download. ...


Autor : TheMax
Category: Software & Web-Development

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial