<?php


class XRange implements Iterator
{
	protected $value = 0;

	protected $limit;

	protected $step;

	protected $initial;

	protected $key = 0;

	public function __construct($value, $limit, $step = 1)
	{
		$this->value = $this->initial = $value;

		$this->limit = $limit;

		$this->step = $step;
	}

	public function rewind()
	{
		$this->value = $this->initial;
	}

	public function current()
	{
		return $this->value;
	}

	public function next()
	{
		$this->value += $this->step;

		++$this->key;
	}

	public function valid()
	{
		return $this->value <= $this->limit;
	}

	public function key()
	{
		return $this->key;
	}
}


foreach(new XRange(1, 10, 1) as $value) {

	echo $value;
}