function randomNumbers ($start,$end,$quantity){
$numbers = range($start, $end);
shuffle($numbers);
return array_slice($numbers,0,$quantity);
}
$array=(randomNumbers(1,10,30));//calling a function
print_r($array);// printing the output
问题是,我只得到10个数字不是30,因为我想。使用php生成1到10之间的30个随机数
那么你基本上试图从10个元素的数组中获得30个元素。所以你可能不想使用'array_splice()'而不是'array_rand()'。 – Rizier123