$this->items = $items; $this->position = 0; } function rewind() { $this->position = 0; } function current() { return $this->items[$this->position]; } function key() { return $this->position; } function next() { ++$this->position; } function valid() { return isset($this->items[$this->position]); } } $customList = new CustomList(); for ($i = 1; $i < 10; $i++) { $customList->add(new CustomObject("Object {$i}")); } foreach ($customList as $obj) { echo $obj->name, "\n"; }