php method to implement different random numbers: first use the range function to generate an array from 0 to 10; then use the shuffle function to randomly shuffle the generated $num array; finally, randomly select the first 5 numbers in the array, that is Can.
Recommended: "PHP Video Tutorial"
Use PHP to generate multiple different random numbers at the same time
Example: Generate 5 different random numbers at the same time
<?php $num = range(0,10);//利用range()函数产生一个0到10的数组 shuffle($num);//利用shuffle()函数将产生的$num数组随机打乱顺序 for ($i=0; $i < 5; $i++) {//选取数组前5个,即随机 echo $num[$i]." "; } ?>
The above is the detailed content of How to implement different random numbers in php. For more information, please follow other related articles on the PHP Chinese website!