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

从给定的字符集生成随机数。PHP,php,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

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

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;

好吧,这就是你需要做的,你有什么问题吗?或者你只是要求我们为你编程?这不是免费的编码服务。在解决问题时,您必须至少表现出最基本的努力。这里有两个函数可以使用,尝试使用
rand(min,max)
从一个范围中选择随机数&
array\u rand(array,number)
从一组预定义的数字中选择随机项。干得好。