min = $min; $this->max = $max; $this->old = $old; $this->queue = array(); for($i = 0; $i < $this->old; $i++) $this->queue[] = $min - 1; $this->qix = 0; } public function getNumber() { do { $res = mt_rand($this->min, $this->max); } while(in_array($res, $this->queue)); $this->queue[$this->qix] = $res; $this->qix = ($this->qix + 1) % $this->old; return $res; } public function getQueue() { return $this->queue; } } session_start(); if(isset($_SESSION['RanHandler'])) { $rh = $_SESSION['RanHandler']; } else { $rh = new RanHandler(1, 100, 10); } echo $rh->getNumber() . "\r\n"; print_r($rh->getQueue()); $_SESSION['RanHandler'] = $rh; ?>