示例#1
0
        $this->_colors = $arr;
    }
    public function fetch()
    {
        $color = each($this->_colors);
        if ($color) {
            return $color['value'];
        } else {
            reset($this->_colors);
            return false;
        }
    }
}
$arr = array("blue", "red", "green", "orange", "white");
$obj = new Colors($arr);
while (($c = $obj->fetch()) != false) {
    echo $c . "<br/>";
}
class Colors2 implements Iterator
{
    private $_colors = array();
    public function __construct($arr)
    {
        $this->_colors = $arr;
        $this->n = count($arr);
    }
    public function rewind()
    {
        $this->start = 0;
    }
    public function valid()