Hello,
I’ve got to make a unique random number as part of a program, I was thinking that a recursive method might be up to the job but seeing as I’ve not messed with recursion I was hoping for advice.
This is what I’ve got:
protected $items = array();
public function create_ref() {
$ref_id = rand();
if (in_array($ref_id, $this->items)) {
$this->create_ref();
}else{
return $ref_id;
}
}
It seems to work, but I was hoping that someone might have done this kind of thing before and either reassure me that I’m not creating a bug or point me in the right direction.
Thanks,
Jon