Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2. class IteratorTest implements Iterator {
  3. private $_items = array(1,2,3,4,5,6,7);
  4. public function __construct() {
  5. ;
  6. }
  7. public function rewind() { reset($this->_items); }
  8. public function current() { return current($this->_items); }
  9. public function key() { return key($this->_items); }
  10. public function next() { return next($this->_items); }
  11. public function valid() { return ($this->current() !== false); }
  12. }
  13. $obj = new test();
  14. foreach($obj as $key => $value) {
  15. print $key . "=>" . $value . "\n";
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement