从给定的字符集生成随机数.PHP


Generate random numbers from given character set. PHP

如何从以下数字列表中生成一个随机数-

a) 1 to 50 (one from the list)
b) 6, 12, 18, 24, 30 (one from the list)
c) 7, 13, 19, 25, 31 (one from the list)
d) 3 to 75 (one from the list)

试试下面的方法吧

$fixarray1 = array(6, 12, 18, 24, 30);
$fixarray2 = array(7, 13, 19, 25, 31);

$arra1 = rand(1, 50);
$arra2 = array_rand($fixarray1,1);
$arra3 = array_rand($fixarray2,1);
$arra4 = rand(3, 75);
echo $arra1."-".$arra2."-".$arra3."-".$arra4;