data = range(1,10); } function current() { return current($this->data); } function key() { return key($this->data); } function next() { return next($this->data); } function rewind() { return ($this->data); } function valid() { return (bool) current($this->data); } function set_val($key, $value) { $this->data[$key] = $value; } } $newdata = new data(); foreach ($newdata as $key => $val) { echo $val.'
'; } foreach ($newdata as $key => $val) { echo $val.'
'; } ?>