Php gets N random numbers within a certain range, random number _ PHP Tutorial

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.