All pastes #748324 Raw Edit

Unnamed

public text v1 · immutable
#748324 ·published 2007-10-24 19:06 UTC
rendered paste body
<?php

class data implements iterator
{
	private $data;
	
	function __construct() 
	{
		$this->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.'<br />';
}

foreach ($newdata as $key => $val)
{
	echo $val.'<br />';

}



?>