options = func_get_args(); $this->num_options = count($this->options); if( is_array($this->options[0]) ) { $this->options = $this->options[0]; $this->num_options = count($this->options); } $this->idx = 0; } public function __toString() { $ret = $this->options[$this->idx++]; if( $this->idx >= $this->num_options ) $this->idx = 0; return $ret; } } //usage $cycle = new Cycle('red','green','blue'); echo $cycle; //red echo $cycle; //green echo $cycle; //blue echo $cycle; //red //outputs redgreenbluered ?>