How to find the mode of an array in PHP

后端 未结 3 1947
清酒与你
清酒与你 2020-12-07 02:56

I have an array that has been sorted from low to high which has over 260k values in. I have found out the mean(average) and median of the array just need to find out the mod

3条回答
  •  忘掉有多难
    2020-12-07 03:22

    The mode of a numerical set is the number that occurs the most often. You can do this with PHP using code similar to the following:

    $values = array_count_values($valueArray); 
    $mode = array_search(max($values), $values);
    

提交回复
热议问题