# PHP searches for the maximum number and minimum number of 10 records in the numeric array without repeating. array number _ PHP Tutorial

Source: Internet
Author: User
PHP searches for the maximum and minimum 10 numbers of arrays in the numeric array. PHP searches for the maximum number and minimum number of 10 records in the numeric array. This article describes how to search for the maximum number and minimum number of 10 records in the numeric array in PHP. Share The PHP method for finding the maximum and minimum 10 numbers of values in the numeric array. the number of arrays

This example describes how to search for the maximum number and the minimum number of 10 records in a numeric array in PHP. Share it with you for your reference. The details are as follows:

1. the php code is as follows:

`// Randomly generate an array of 10 thousand elements for (\$ I = 0; \$ I <10000; \$ I ++) {\$ ary [] = rand );} \$ ary = array_unique (\$ ary); // deduplicated value sort (\$ ary); // ordered \$ min_10 = array_slice (\$ ary, 0, 10 ); // obtain the minimum 10 values \$ max_10 = array_slice (\$ ary,-10, 10); // obtain the maximum 10 values rsort (\$ max_10 ); // Top 10 values in reverse order: echo'';print_r(\$min_10);print_r(\$max_10);unset(\$ary,\$min_10,\$max_10);2. the running result is as follows:Array(  [0] => 16  [1] => 19  [2] => 22  [3] => 31  [4] => 40  [5] => 49  [6] => 71  [7] => 74  [8] => 80  [9] => 92)Array(  [0] => 99997  [1] => 99991  [2] => 99973  [3] => 99958  [4] => 99955  [5] => 99946  [6] => 99939  [7] => 99933  [8] => 99927  [9] => 99900)I hope this article will help you with php programming.Examples in this article describes how to search for the maximum number and the minimum number of 10 records in a numeric array in PHP without repeating. Share...`
Related Keywords:

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.