Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement