I have previously told you how to generate multiple random numbers. next I will introduce how to generate N non-repeated random number instances in php. if you are interested, refer to it. It is not difficult to implement this function, but I have learned a lot .? Php * nbs... I have previously told you how to generate multiple random numbers. next I will introduce how to generate N non-repeated random number instances in php. if you are interested, refer to it.
It is not difficult to implement this function, but I have learned a lot.
The mt_rand () function is used to generate a random number. The average speed of this function to generate random numbers is four times faster than rand.
The "Flip method" is used to remove duplicate values in the array, that is, the key and value of the array are exchanged twice with array_flip. This approach is much faster than using array_unique.
Before returning an array, use shuffle () to assign a new key name to the array to ensure that the key name is a continuous number ranging from 0 to n. If you do not perform this step, the key name may not be consecutive when you delete duplicate values, which may cause trouble for traversal.
Address:
Reprinted at will, but please attach the article address :-)