开发者

How to genenerate 24 random numbers between 1 and 24 in PHP?

开发者 https://www.devze.com 2023-01-21 06:56 出处:网络
For this Wordpress site, I need to generate 24 variables each of which contains a number be开发者_运维百科tween 1 and 24. The problem is that two variables cannot have the same value. So I basically n

For this Wordpress site, I need to generate 24 variables each of which contains a number be开发者_运维百科tween 1 and 24. The problem is that two variables cannot have the same value. So I basically need to generate 24 variables each of which contains a number between 1 and 24.

Here's the code that I am using to generate a random number.

$mirza = rand(1,24);

Thanks for any help.


You can use shuffle

$numbers = range(1, 24);
shuffle($numbers);


$a = range(1,24);
shuffle ( $a );
0

精彩评论

暂无评论...
验证码 换一张
取 消