If you want to find the AVERAGE of the values in your array, use the sum and count functions together. For example, let's say your array is $foo and you want the average...
<?php $foo = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); $average_of_foo_round = floor(array_sum($foo) / count($foo)); $average_of_foo = (array_sum($foo) / count($foo)); echo "Average value Round fractions is ".$average_of_foo_round."<br/>"; echo "Average value is ".$average_of_foo."<br/>"; ?> // Output Average value Round fractions is 10 Average value is 10.5
0 Comments