class b implements Iterator
{
private $p = 0;
private $d = [];
function add($o1, $o2)
{
$this->d[] = [$o1, $o2];
}
function key()
{
return $this->d[$this->p][0];
}
function rewind()
{
$this->p = 0;
}
function current()
{
return $this->d[$this->p][1];
}
function next()
{
++$this->p;
}
function valid()
{
return isset($this->d[$this->p]);
}
}
$b = new b;
$b->add(new Str, new Str);
foreach($b as $k => $v)
var_dump($k); // object Str
Comments