Get a specified number of random numbers from the specified range, which are not repeated. first, put the specified range into an array and retrieve the number from the array, this number is removed from the array every time you extract it. This prevents the number from being Retrieved again next time, so as to achieve non-repetition. get a specified number of random numbers from the specified range, which are not repeated. first, put the specified range into an array and retrieve the number from the array, this number is removed from the array every time you extract it. This prevents the number from being Retrieved again next time, so as to achieve non-repetition.
// Obtain a random number from 100 natural numbers $ List = 100; // Take a few $ Nu = 10; For ($ s; $ s <$ list; $ s ++ ){ $ A [] = $ s; }
For ($ I; $ I <$ nu; $ I = $ key ){ For ($ n = rand (0, ($ list-1); $ a [$ n] ==n n; $ a [$ n] = $ list) { $ Key ++; $ Num [] = $ n; } } Print_r ($ num ); ?> |