It mainly uses built-in functions, and has tried multiple methods to quickly sort and merge data. No built-in functions can be used to process data quickly! Sort () uses quick sorting! No random array of 10 thousand elements is generated for ($ i0; $ i10000; $ I ++) {$ ary [] rand ();} $ aryarray_unique ($ ary ); distinct value sort ($ ary); sequential sorting $ min_10array_sl
It mainly uses built-in functions, and has tried multiple methods to quickly sort and merge data. No built-in functions can be used to process data quickly! Sort () uses quick sorting! No // randomly generate an array of 10 thousand elements for ($ I = 0; $ i10000; $ I ++) {$ ary [] = rand );} $ ary = array_unique ($ ary); // deduplicated value sort ($ ary); // ordered $ min_10 = array_sl
It mainly uses built-in functions, and has tried multiple methods to quickly sort and merge data. No built-in functions can be used to process data quickly! Sort () uses quick sorting! <无>
// 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);
// Run the result 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)