0

How can I do this, not to show only min and max number, but all numbers like 23,45,65,78,34,21,56

I need command to sort this out from min to max and display it, then get avarage number and display it too

Thanks in advance

3
Contributors
5
Replies
20
Views
3 Years
Discussion Span
Last Post by filipgothic
0

ok I did one part, now I need to get avarage number from those 7 numbers

<?php

$points = array(77, 98, 56, 87, 64, 55, 82);
sort($points);
foreach ($points as $key => $val) {
    echo "Student[" . $key . "] = " . $val . "\n";
}

?>
0

There is no real function for this that I know of. Just find average when you traverse through the array. Simple Programming. If you don't know how to make a program to calculate average, I'm afraid you need to get much better at prgoramming then.

2
echo array_sum($points)/count($points);
Votes + Comments
I didn't know there is a function to calculate sum of array as well. PHP just doesn't want us to do anything.
0

i just did that and this

echo "Totalni broj poena = " . array_sum($points) . "\n";

echo $avg = array_sum($points)/count($points);

thanks for help

solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.