- reset: documentation ( source)
- key: documentation ( source)
- next: documentation ( source)
- current: documentation ( source)
<?php
class Shiterator implements Iterator {
private $_array = array();
public function __construct(array $array) {
$this->_array = $array;
}
public function rewind() {
reset($this->_array);
}
public function current() {
return current($this->_array);
}
public function key() {
return key($this->_array);
}
public function next() {
next($this->_array);
}
public function valid() {
return $this->key() !== null;
}
}
$stdcls = new stdClass();
$stdcls->message = 'PHP, still a peice of shit.';
$i = new Shiterator(array(stdcls));
foreach ($i as $t) {
echo $t->message;
}