Php obtains N random numbers and random numbers within a certain range. Php obtains N non-repeated random numbers within a certain range. This article describes how php obtains N non-repeated random numbers within a certain range. For your reference, php obtains N random numbers and random numbers within a certain range.
This example describes how php can obtain N non-repeated random numbers within a certain range. We will share this with you for your reference. The details are as follows:
// Range is an array of columns from 1000 to 9999. $ numbers = range (, 9999); // shuffle will immediately shuffle the array order ($ numbers ); // array_slice get a certain segment of the array $ result = array_slice ($ numbers,); print_r ($ result );
The running result is:
Array ([0] => 9767 [1] => 2344 [2] => 7783)
Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming:
Php code online formatting and beautification tools:
Http://tools.jb51.net/code/phpformat
In addition, because php belongs to the C language style, the following tool can also format php code:
C language style/HTML/CSS/json code formatting and beautification tools:
Http://tools.jb51.net/code/ccode_html_css_json