This example describes a method for PHP to find the maximum and minimum number of 10 digits in a numeric array. Share to everyone for your reference. Specifically as follows:
1. PHP code is as follows:
An array of randomly generated 10,000 elements for
($i =0 $i <10000; $i + +) {
$ary []=rand (1,100000);
}
$ary =array_unique ($ary); Go to repeat
the value sort ($ary),//order sort
$min _10=array_slice ($ary, 0, 10), and/or remove the smallest 10 values
$max _10=array_slice ($ary, 10 , 10)//Remove the largest 10 numeric
rsort ($max _10);//reverse order the largest 10 numeric
echo ' <pre> ';
Print_r ($min _10);
Print_r ($max _10);
Unset ($ary, $min _10, $max _10);
2. The results of the operation are as follows:
Array
(
[0] =>
[1] =>
[2] =>
[3] => to
[4] =>
[5] => 49
[6] => [
7] => [
8] =>
[9] =>-a
)
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 your PHP program design.