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

时间:2016-10-18 04:19:56

标签: 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)

1 个答案:

答案 0 :(得分:1)

尝试以下内容可以帮助您

$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;