TOPK category, used to count the frequency of occurrence of words, report, and data statistics! No random value array is generated for ($ i0; $ i1000; $ I ++) {$ ary [] rand () ;}$ aryarray_count_values ($ ary ); count the number of occurrences of all values in the array. arsort ($ ary); sort in reverse order $ i1; foreach ($ aryas $ key $ value ){
TOPK category, used to count the frequency of occurrence of words, report, and data statistics! No // randomly generated value array for ($ I = 0; $ i1000; $ I ++) {$ ary [] = rand );} $ ary = array_count_values ($ ary); // count the number of times all values in the array appear. arsort ($ ary); // sort in reverse order $ I = 1; foreach ($ ary as $ key = $ value ){
TOPK category, used to count the frequency of occurrence of words, report, and data statistics! <无>
// Randomly generate a value array for ($ I = 0; $ I <1000; $ I ++) {$ ary [] = rand );} $ ary = array_count_values ($ ary); // count the number of times all values in the array appear. arsort ($ ary); // sort in reverse order $ I = 1; foreach ($ ary as $ key = >$ value) {if ($ I <= 10) {printf ("number: % d appears % d in total
", $ Key, $ value) ;}else {break ;}$ I ++;} unset ($ ary); // result number: 255 6 times in total: 443: 5 times in total: 906: 5 times in total: 623: 5 times in total: 586: 4 times in total: 660: 4 times in total: 873 appear 4 times: 208 appear 4 times: 247 appear 4 times: 240 appear 4 times: appear 4 times