- var_dump: documentation ( source)
<?php
class IncrementIterator implements iterator {
protected $start;
protected $end;
protected $current;
public function __construct($start, $end) {
$this->start = $start;
$this->end = $end;
}
public function rewind() {
$this->current = $this->start;
}
public function valid() {
return $this->current <= $this->end;
}
public function key() {
return $this->current;
}
public function current() {
return $this->current;
}
public function next() {
$this->current++;
}
}
$aIterator = new IncrementIterator(0, 26);
$bIterator = new IncrementIterator(0, 26);
$cIterator = new IncrementIterator(0, 26);
$dIterator = new IncrementIterator(0, 26);
$multipleIterator = new MultipleIterator();
$multipleIterator->attachIterator($aIterator);
$multipleIterator->attachIterator($bIterator);
$multipleIterator->attachIterator($cIterator);
$multipleIterator->attachIterator($dIterator);
foreach ($multipleIterator as $current) {
var_dump($current);
}