我正在尝试生成一个包含异常的唯一随机数组,我已经做到了这一点:
function rand_except($min, $max,$no_numbers, $except) {
//loop until you get a unique randomized array without except number
$end=false;
while (!$end){
$numbers = rand_array($min, $max,$no_numbers);//get unique randomized array
if(!in_array($except,$numbers)){
$end=true;
break;
}
}
return $numbers;
}
但现在我希望函数循环,直到 except 参数不在数组中